错误:
今天想在实验室的GPU服务器-我的docker容器里使用tensorflow-gpu【安装直接pip install tensorflow-gpu】,结果报错:
1. ImportError: Traceback (most recent call last): 2. File "/root/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module> 3. from tensorflow.python.pywrap_tensorflow_internal import * 4. File "/root/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module> 5. _pywrap_tensorflow_internal = swig_import_helper() 6. File "/root/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper 7. _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) 8. File "/root/anaconda3/lib/python3.6/imp.py", line 243, in load_module 9. return load_dynamic(name, filename, file) 10. File "/root/anaconda3/lib/python3.6/imp.py", line 343, in load_dynamic 11. return _load(spec) 12. ImportError: libcublas.so.10.0: cannot open shared object file: No such file or directory 13. 14. 15. Failed to load the native TensorFlow runtime.
原因很简单:tensorflow和docker里的cuda版本不对应:
1. Latest TensorFlow supports cuda 8-10. cudnn 6-7. 2. Each TensorFlow binary has to work with the version of cuda and cudnn it was built with. If they don't match, you have to change either the TensorFlow binary or the Nvidia softwares. 3. Official tensorflow-gpu binaries (the one downloaded by pip or conda) are built with cuda 9.0, cudnn 7 since TF 1.5, and cuda 10.0, cudnn 7 since TF 1.13. These are written in the release notes. You have to use the matching version of cuda if using the official binaries. 4. If you don't like to change your Nvidia software, you can: 5. (1) Use a different version of TensorFlow 6. (2) Use non-official binaries built by others. e.g.: https://github.com/mind/wheels/releases, https://github.com/hadim/docker-tensorflow-builder#builds, 7. https://github.com/inoryy/tensorflow-optimized-wheels 8. (3) Build the binaries by yourself from source with your version of Nvidia software.
安装好对应的版本就好了:更多请参阅这篇文章:https://blog.csdn.net/qq_36396104/article/details/89165185
1. tensorflow-gpu v1.9.0 | cuda9.0 | cuDNN7.1.4可行 | 备注:7.0.4/ 7.0.5/ 7.1.2不明确 2. 3. tensorflow-gpu v1.8.0 | cuda9.0 | cuDNN 不明确 | 备注:7.0.4/ 7.0.5/ 7.1.2/ 7.1.4 4. 5. tensorflow-gpu v1.7.0 | cuda9.0 | cuDNN 不明确 | 备注:7.0.4/ 7.0.5/ 7.1.2/ 7.1.4 6. 7. tensorflow-gpu v1.6.0 | cuda9.0 | cuDNN 不明确 | 备注:7.0.4/ 7.0.5/ 7.1.2/ 7.1.4 8. 9. tensorflow-gpu v1.5.0 | cuda9.0 | cuDNN 不明确 | 备注:7.0.4/ 7.0.5/ 7.1.2/ 7.1.4 10. 11. tensorflow-gpu v1.4.0 | cuda8.0 | cuDNN 6.0 | 备注:6.0正常使用, 7.0.5不能用,5.1未知 12. 13. tensorflow-gpu v1.3.0 | cuda8.0 | cuDNN 6.0 | 备注:6.0正常使用, 7.0.5不能用,5.1未知 14. 15. tensorflow-gpu v1.2.0 | cuda8.0 | cuDNN 5.1 | 备注:5.1正常使用, 6.0/ 7.0.5 未知 16. 17. tensorflow-gpu v1.1.0 | cuda8.0 | cuDNN 5.1 | 备注:5.1正常使用, 6.0/ 7.0.5 未知
步骤:
1、查看cuda版本:
1. cat /usr/local/cuda/version.txt #shows CUDA Version 9.0.176 2. or 3. nvcc -V
2、安装对应版本的tensorflow【我的是9.0】:
pip install tensorflow-gpu==1.7.0
AIEarth是一个由众多领域内专家博主共同打造的学术平台,旨在建设一个拥抱智慧未来的学术殿堂!【平台地址:https://devpress.csdn.net/aiearth】 很高兴认识你!加入我们共同进步!