linux下theano/tensorflow安装cuda支持gpu
2016-09-10 10:14
706 查看
本人在安装过程中碰到很多问题,一一记录下来
1.theano运行gpu,测试代码如下
最新版 的theano 运行报错,错误内容如下:
nvcc fatal : Value 'sm_61' is not defined for option 'gpu-architecture'
错误原因,sm_61需要cuda8.0的才能运行,安装cuda8.0
在安装目录运行如下命令:./cuda_8.0.27_linux.run
执行如下代码: ldconfig /usr/local/cuda/lib64
2.tensorflow运行gpu,测试代码如下:
ImportError: libcudart.so.7.5: cannot open shared object file: No such file or directory
就上面的信息而言,tensorflow不支持cuda8,重新安装cuda7.5
在安装目录执行 ./cuda_7.5.18_linux.run
安装完成后继续出现如下错误:
ImportError: libcudart.so.7.5: cannot open shared object file: No such file or directory
执行如下代码:ldconfig /usr/local/cuda/lib64
重新运行:
目前最新的theano/tensorflow不能共用一个cuda
如果要在cuda7.5/8.0切换,可以执行如下代码
# rm -rf cuda
# ln -s cuda-8.0 cuda
# ldconfig /usr/local/cuda/lib64
1.theano运行gpu,测试代码如下
vlen = 10 * 30 * 768 # 10 x #cores x # threads per core iters = 1000 rng = numpy.random.RandomState(22) x = shared(numpy.asarray(rng.rand(vlen), config.floatX)) f = function([], T.exp(x)) print(f.maker.fgraph.toposort()) t0 = time.time() for i in range(iters): r = f() t1 = time.time() print("Looping %d times took %f seconds" % (iters, t1 - t0)) print("Result is %s" % (r,)) if numpy.any([isinstance(x.op, T.Elemwise) for x in f.maker.fgraph.toposort()]): print('Used the cpu') else: print('Used the gpu')
最新版 的theano 运行报错,错误内容如下:
nvcc fatal : Value 'sm_61' is not defined for option 'gpu-architecture'
错误原因,sm_61需要cuda8.0的才能运行,安装cuda8.0
在安装目录运行如下命令:./cuda_8.0.27_linux.run
Do you accept the previously read EULA? accept/decline/quit: accept You are attempting to install on an unsupported configuration. Do you wish to continue? (y)es/(n)o [ default is no ]: y Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 361.77? (y)es/(n)o/(q)uit: n Install the CUDA 8.0 Toolkit? (y)es/(n)o/(q)uit: y Enter Toolkit Location [ default is /usr/local/cuda-8.0 ]: /usr/local/cuda-8.0 is not writable. Do you wish to run the installation with 'sudo'? (y)es/(n)o: y Do you want to install a symbolic link at /usr/local/cuda? (y)es/(n)o/(q)uit: y Install the CUDA 8.0 Samples? (y)es/(n)o/(q)uit: y Enter CUDA Samples Location [ default is /home/homolo ]: Installing the CUDA Toolkit in /usr/local/cuda-8.0 ...安装之后重新运行测试代码报错:
ERROR (theano.sandbox.cuda): Failed to compile cuda_ndarray.cu: libcublas.so.8.0: cannot open shared object file: No such file or directory WARNING (theano.sandbox.cuda): CUDA is installed, but device gpu is not available (error: cuda unavailable) [Elemwise{exp,no_inplace}(<TensorType(float32, vector)>)] Looping 1000 times took 2.026935 seconds Result is [ 1.23178029 1.61879337 1.52278066 ..., 2.20771813 2.29967761 1.62323284] Used the cpu错误原因是文件找不到,解决办法:
执行如下代码: ldconfig /usr/local/cuda/lib64
2.tensorflow运行gpu,测试代码如下:
hello = tf.constant("hello TensorFlow!") sess=tf.Session() print(sess.run(hello)) a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a') b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b') c = tf.matmul(a, b) sess = tf.Session(config=tf.ConfigProto(log_device_placement=True)) print(sess.run(c))在cuda8.0上,运行报错,错误信息如下:
ImportError: libcudart.so.7.5: cannot open shared object file: No such file or directory
就上面的信息而言,tensorflow不支持cuda8,重新安装cuda7.5
在安装目录执行 ./cuda_7.5.18_linux.run
Do you accept the previously read EULA? (accept/decline/quit): accept You are attempting to install on an unsupported configuration. Do you wish to continue? ((y)es/(n)o) [ default is no ]: y Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 352.39? ((y)es/(n)o/(q)uit): n Install the CUDA 7.5 Toolkit? ((y)es/(n)o/(q)uit): y Enter Toolkit Location [ default is /usr/local/cuda-7.5 ]: y Toolkit location must be an absolute path. Enter Toolkit Location [ default is /usr/local/cuda-7.5 ]: /usr/local/cuda-7.5 is not writable. Do you wish to run the installation with 'sudo'? ((y)es/(n)o): y Do you want to install a symbolic link at /usr/local/cuda? ((y)es/(n)o/(q)uit): y Install the CUDA 7.5 Samples? ((y)es/(n)o/(q)uit): y Enter CUDA Samples Location [ default is /home/homolo ]: Installing the CUDA Toolkit in /usr/local/cuda-7.5 ...
安装完成后继续出现如下错误:
ImportError: libcudart.so.7.5: cannot open shared object file: No such file or directory
执行如下代码:ldconfig /usr/local/cuda/lib64
重新运行:
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcublas.so locally I tensorflow/stream_executor/dso_loader.cc:102] Couldn't open CUDA library libcudnn.so. LD_LIBRARY_PATH: /data/work/pycharm-2016.1.4/bin: I tensorflow/stream_executor/cuda/cuda_dnn.cc:2259] Unable to load cuDNN DSO I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcufft.so locally I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcuda.so.1 locally I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcurand.so locally I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:925] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero I tensorflow/core/common_runtime/gpu/gpu_init.cc:102] Found device 0 with properties: name: GeForce GTX 1060 6GB major: 6 minor: 1 memoryClockRate (GHz) 1.7845 pciBusID 0000:01:00.0 Total memory: 5.93GiB Free memory: 5.47GiB I tensorflow/core/common_runtime/gpu/gpu_init.cc:126] DMA: 0 I tensorflow/core/common_runtime/gpu/gpu_init.cc:136] 0: Y I tensorflow/core/common_runtime/gpu/gpu_device.cc:838] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1060 6GB, pci bus id: 0000:01:00.0) b'hello TensorFlow!' Device mapping: /job:localhost/replica:0/task:0/gpu:0 -> device: 0, name: GeForce GTX 1060 6GB, pci bus id: 0000:01:00.0 I tensorflow/core/common_runtime/gpu/gpu_device.cc:838] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1060 6GB, pci bus id: 0000:01:00.0) I tensorflow/core/common_runtime/direct_session.cc:175] Device mapping: /job:localhost/replica:0/task:0/gpu:0 -> device: 0, name: GeForce GTX 1060 6GB, pci bus id: 0000:01:00.0 I tensorflow/core/common_runtime/simple_placer.cc:818] MatMul: /job:localhost/replica:0/task:0/gpu:0 I tensorflow/core/common_runtime/simple_placer.cc:818] b: /job:localhost/replica:0/task:0/gpu:0 I tensorflow/core/common_runtime/simple_placer.cc:818] a: /job:localhost/replica:0/task:0/gpu:0 I tensorflow/core/common_runtime/simple_placer.cc:818] Const: /job:localhost/replica:0/task:0/cpu:0 MatMul: /job:localhost/replica:0/task:0/gpu:0 b: /job:localhost/replica:0/task:0/gpu:0 a: /job:localhost/replica:0/task:0/gpu:0 Const: /job:localhost/replica:0/task:0/cpu:0 [[ 22. 28.] [ 49. 64.]]
目前最新的theano/tensorflow不能共用一个cuda
如果要在cuda7.5/8.0切换,可以执行如下代码
# rm -rf cuda
# ln -s cuda-8.0 cuda
# ldconfig /usr/local/cuda/lib64
相关文章推荐
- 深度工具合集安装(Nvidia+CUDA+cuDNN+Tensorflow+OpenBLAS+Caffe+Theano+Keras+Torch+Mxnet+X2Go)
- Ubuntu14.04 & CUDA8.0 & Theano & Tensorflow & TensorLayer & Cudnn安装血泪史
- ubuntu14.04+GTX960+cuda8.0+cudnn5.1+Theano+Tensorflow安装教程
- 深度工具合集安装(Nvidia+CUDA+cuDNN+Tensorflow+OpenBLAS+Caffe+Theano+Keras+Torch+Mxnet+X2Go)
- 第一篇文章献给艰难的Ubuntu16.04安装caffe之旅 cuda tensorflow Theano
- 在U盘里配置好主流深度学习框架及GPU环境theano\tensorflow\keras\caffe\cuda7.5
- linux下 安装anaconda NVIDIA显卡驱动 cuda cudnn tensorflow-gpu 线下安装!
- windows 四行命令安装 theano tensorflow keras
- Win7/Win10环境安装:Cuda+keras+tensorflow-gpu
- linux install Theano+Tensorflow+Keras
- ubuntu 14.04 server搭建+NVIDIA+CUDA+CUDNN+caffe+theano+tensorflow+keras+matlab
- 在 Ubuntu16.04上安装anaconda+Spyder+TensorFlow(支持GPU)
- 在 Ubuntu 16.04 中安装支持 CPU 和 GPU 的 Google TensorFlow 神经网络软件
- 深度学习python库安装经验,Windows下安装Anaconda3 pycharm tensorflow keras theano中遇到的问题
- Ubuntu16.04+CUDA8.0+CUNN5.1+caffe+tensorflow+Theano
- 在win10上安装Theano+tensorflow
- Ubuntu16.04 +cuda8.0+cudnn+opencv+caffe+theano+tensorflow配置明细
- Ubuntu16.04 + gtx1060 + cuda8.0 + cudnn5.1 + caffe + Theano + Tensorflow
- Ubuntu16.04 +cuda8.0+cudnn+opencv+caffe+theano+tensorflow配置明细
- Anaconda+Tensorflow+Theano+Keras安装