Ubuntu 16.04 系统安装 and Tensorflow-gpu and CUDA and CUDNN

制作16.04 系统安装U盘(使用Rufus 3.4制作Ubuntu 18.04.1 U盘启动盘的方法)

https://ywnz.com/linuxjc/3978.html

1 安装16.04

https://blog.csdn.net/zhengchaooo/article/details/79500209

安装过程中如果出现CD-ROM读取不到 可以将U盘拔出再插上 然后再重复一次读取CD-ROM的操作(奇怪的现象)

2 16.04 安装的是python 是2.7 和 3.5

3 替换python版本 为python3.6


操作:

参考步骤https://www.cnblogs.com/gaowengang/p/7736672.html

http://www.cnblogs.com/yqpy/p/9116590.html

1、打开终端

首先创建安装目录,

sudo mkdir /usr/local/python3

2、然后下载安装包,解压,并且进入

wget --no-check-certificate https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz

tar -xzvf Python-3.6.5.tgz

cd Python-3.6.5

3、接着编译安装

sudo ./configure --prefix=/usr/local/python3

sudo make

sudo make install

如果第一步编译的时候出现了报错,则试试

sudo apt-get install build-essential

4、创建python3的链接

sudo ln -s /usr/local/python3/bin/python3 /usr/bin/python3

问题1

ln: failed to create symbolic link '/usr/bin/python3': File exists

说明已经有链接链到 /usr/bin/python上了,删除即可,使用命令

rm -rf /usr/bin/python3

问题2

zipimport.ZipImportError: can't decompress data; zlib not available

(1)先安装系统相应的依赖库文件

 sudo apt-get install zlibc zlib1g-dev

然后重新编译安装

https://zhoujianghai.iteye.com/blog/1521993


python3.6.3 安装:

tar -zxvf Python-3.6.3.tgz

cd Python-3.6.3

./configure

make

make altinstall

 `make altinstall` , 报错: 

zipimport.ZipImportError: can't decompress data; zlib not available

解决:

cd Modules/zlib

./configure

make install

cd -

make altinstall

https://blog.csdn.net/jaket5219999/article/details/78583604


问题3

Ubuntu下“pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.”

sudo apt-get install python3-dev libffi-dev libssl-dev

wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz 

tar xvf Python-3.6.0.tgz

cd Python-3.6.0

./configure --enable-optimizations   --prefix=/usr/local/python3

make -j8 

sudo make altinstall

python3.6

ubuntu16.04中将python3设置为默认

直接执行这两个命令即可:

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150

Ubuntu下pip3的安装、升级、卸载

安装

sudo apt-get install python3-pip

升级

sudo pip3 install --upgrade pip

卸载

sudo apt-get remove python3-pi

http://www.lxins.com/2017/08/03/ubuntu%E4%B8%8Bpip-is-configured-with-locations-that-require-tlsssl-however-the-ssl-module-in-python-is-not-available/


安装

pip3 install tensorflow-gpu==1.10 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com --user


4 Linux 装好后需要相互拷贝文件 可以在windows 上新建共享文件夹 然后在ubuntu 上挂载

挂载windows 共享文件夹 mount -t cifs //192.168.1.111/Share ./windows -o username=***,password=*****,vers=2.0


5 CUDA 9.0

https://developer.nvidia.com/cuda-90-download-archive?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1604&target_type=runfilelocal

https://blog.csdn.net/wanzhen4330/article/details/81699769

https://developer.download.nvidia.cn/compute/cuda/9.0/Prod/docs/sidebar/CUDA_Quick_Start_Guide.pdf

6 安装CUDnn

https://developer.nvidia.com/rdp/cudnn-download

https://medium.com/beesightsoft/install-tensorflow-gpu-pytorch-on-ubuntu-18-04-dell-t1700-3e66bcab07a6

# Install

sudo dpkg -i libcudnn7_7.4.2.24-1+cuda9.0_amd64.deb

sudo dpkg -i libcudnn7-dev_7.4.2.24-1+cuda9.0_amd64.deb

sudo dpkg -i libcudnn7-doc_7.4.2.24-1+cuda9.0_amd64.deb


7 pip安装whl文件

 pip install some.whl

8 运行实例

https://blog.csdn.net/qq_29893385/article/details/82084108

问题

ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory

https://blog.csdn.net/qq_34374211/article/details/81018320

sudo vim ~/.bashrc

在末尾加入:

export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}

export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

export CUDA_HOME=/usr/local/cuda

source ~/.bashrc

发现此时import tensorflow还是报一样的错误,所以进行步骤二

步骤二

检查 /usr/local/cuda-9.0/lib64 下是否有 libcublas.so.9.0

如果有,终端输入:

sudo ldconfig /usr/local/cuda-9.0/lib64

你可能感兴趣的:(Ubuntu 16.04 系统安装 and Tensorflow-gpu and CUDA and CUDNN)