admin管理员组文章数量:1565776
得不说坑好多……
在这里先说在前面 最好的组合是cuda8 cudnn6 不要问我为什么……都是泪!!!
cuda9 tensorflow前段时间说是兼容了,但是不好按,会报错
cudnn我按官网上面是5 for cuda8 ,python里import时还会报错
tensorflow 默认安装还是会报错(默认是1.6)
具体错误文后贴出……
cuda8 cuDnn6 网盘:网盘 密码: qr4i
Ubuntu初始环境设置
- 打开
终端
输入:
# 系统升级
>>> sudo apt update
>>> sudo apt upgrade
# 安装python基础开发包
>>> sudo apt install -y python-dev python-pip python-nose gcc g++ git gfortran vim
- 安装运算加速库打开
终端
输入:
>>> sudo apt install -y libopenblas-dev liblapack-dev libatlas-base-dev
1. CUDA开发环境的搭建(CPU加速跳过)
如果您的仅仅采用cpu加速,可跳过此步骤 - 下载CUDA8.0
下载地址:https://developer.nvidia/cuda-downloads
之后打开终端
输入:
>>> sudo dpkg -i cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64.deb
>>> sudo apt update
>>> sudo apt -y install cuda
自动配置成功就好。
- 将CUDA路径添加至环境变量在
终端
输入:
>>> sudo gedit /etc/profile
在profile
文件中添加:
export CUDA_HOME=/usr/local/cuda-8.0
export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
之后source /etc/profile
即可
- 测试在
终端
输入:
>>> nvcc -V
会得到相应的nvcc编译器相应的信息,那么CUDA配置成功了。(记得重启系统)
如果要进行cuda性能测试
,可以进行:
>>> cd /usr/local/cuda/samples
>>> sudo make -j8
编译完成后,可以进samples/bin/.../.../...
的底层目录,运行各类实例。
2. 加速库cuDNN(可选)建议选6
从官网下载需要注册账号申请,两三天批准。网盘搜索一般也能找到最新版。Linux目前最新的版本是cudnn V6,但对于tensorflow的预编译版本还不支持这个最近版本,建议采用5.1版本,即是cudnn-8.0-win-x64-v5.1-prod.zip。下载解压出来是名为cuda的文件夹,里面有bin、include、lib,将三个文件夹复制到安装CUDA的地方覆盖对应文件夹,在终端中输入:
>>> sudo cp include/cudnn.h /usr/local/cuda/include/
>>> sudo cp lib64/* /usr/local/cuda/lib64/
>>> cd /usr/local/cuda/lib64
>>> sudo ln -sf libcudnn.so.5.1.10 libcudnn.so.5
>>> sudo ln -sf libcudnn.so.5 libcudnn.so
>>> sudo ldconfig -v
3.Keras框架搭建
相关开发包安装
在终端
中输入:(一定是1.4 安装tensorflow时)
>>> sudo pip install -U --pre pip setuptools wheel
>>> sudo pip install -U --pre numpy scipy matplotlib scikit-learn scikit-image
>>> sudo pip install -U --pre tensorflow-gpu==1.4
# >>> sudo pip install -U --pre tensorflow ## CPU版本
>>> sudo pip install -U --pre keras
安装完毕后,输入python
,然后输入:
>>> import tensorflow
>>> import keras
无错输出即可
Keras中mnist数据集测试
下载Keras开发包
>>> git clone https://github.com/fchollet/keras.git
>>> cd keras/examples/
>>> python mnist_mlp.py
程序无错进行,至此,keras安装完成。
遇到的错误
1.
安装的是CUDA8没有安装cudnn
安装tensorflow没有报错
但在import tensorflow时报错
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File …………………………………………p, pathname, description)
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
See https://www.tensorflow/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
2.
安装了cudnn
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 24, in
from tensorflow.python import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 49, in
from tensorflow.python import pywrap_tensorflow
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 72, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: libcudnn.so.6: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
See https://www.tensorflow/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
3.将tensorflow 1.6卸载后,装了1.4,变成
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 24, in
from tensorflow.python import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 49, in
from tensorflow.python import pywrap_tensorflow
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 72, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: libcudnn.so.6: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
See https://www.tensorflow/install/install_sources#common_installation_problems
版权声明:本文标题:华硕 飞行堡垒 linux安装cuda8+cuDnn6+tensorflow+keras 教程 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dongtai/1726524732a1073901.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论