3 2使用conda安裝theano環境

2021-07-26 04:26:20 字數 1419 閱讀 9092

(一)安裝theano

sudo -h /usr/local/anaconda2/bin/conda create -n pyml python=2.7

sudo -h /usr/local/anaconda2/bin/conda install -n pyml jupyter_contrib_nbextensions

sudo -h /usr/local/anaconda2/bin/conda install -n pyml matplotlib numpy scipy sympy pandas scikit-learn nose

sudo -h /usr/local/anaconda2/envs/pyml/bin/pip install --upgrade --no-deps git+git:

(二)配置

vim ~/.theanorc
輸入如下內容,並儲存

[global]

floatx=float32

device=gpu

[lib]

cnmem = 0.8

[blas]

ldflags = -lopenblas

[nvcc]

fastmath = true

(三)測試theano

建立乙個py的檔案,可以是test.py

裡面寫入:

# filename: demo.py

import theano

from theano import tensor

a = tensor.dscalar()

b = tensor.dscalar()

c = a+b

f = theano.function([a, b], c)

assert

4.0 == f(1.5, 2.5)

並儲存。

終端輸入命令:

python  test.py
若無報錯即安裝完成。

在編譯運用theano的python**時候

會爆出下面的錯誤:

error (theano.sandbox.cuda): failed to compile cuda_ndarray.cu: libcublas.so.6.0: cannot open shared object file: no such file or directory

解決辦法終端:

sudo ldconfig /usr/local/cuda /lib64
(四)測試theano使用gpu

見測試篇章

windows安裝keras(不帶theano)

安裝完tensorflow後,很多人想在tensorflow中使用keras keras中封裝了很多高階api使用起來很方便很簡潔,在windows中安裝keras教程很多。大部分都要安裝theano作為後端,theano在windows中安裝有時候會產生很多問題。這裡介紹一種安裝keras的方法,...

安裝tensorflow 使用conda

1.安裝anaconda 2.建立乙個tensorflow的執行環境 python 3.7 conda create n tensorflow python 3.7 3.2 conda方式 conda上面目前有人已經做好了tensorflow的pkg,但是版本不一定最新,且只有cpu版本,不支援gp...

使用conda安裝rasterio

由於rasterio目前支援的gdal版本為1.11.x到2.4.x.而目前conda自動安裝的gdal版本為3.x,因此在rasterio時需要指定gdal版本 如果已經安裝了gdal3.x版本,需要先解除安裝 conda remove rasterio gdal y然後執行安裝 conda in...