目录
安装各个工具
1、gedit:
2、yum
3、weget(没必要装)
4、zip、unzip(先装着 还没用到)
5、vim安装
查看各个版本:
查看Linux版本:
cuda版本查看:
CuDnn版本查看:
CudNN的安装:
Python版本切换
安装依赖库
1、pip
2、pip换源
3、opencv
4、tensorflow下载
5、tensorflow-plot和cython
编译项目和跑项目
首先 实验室的镜像版本写着
注意:实验室的私人数据在 /opt/data/private 目录下
安装各个工具下载失败的时候想想是不是VPN问题,把CFW关了!!!!
先更新
1、gedit:sudo apt-get update
2、yumsudo apt-get install gedit
(ubuntu是不能直接用yum的,会缺乏源,还是用apt-get吧。具体参考Ubuntu中使用yum_2241431065的博客-CSDN博客_ubuntu使用yum
)不用下载了
3、weget(没必要装) 4、zip、unzip(先装着 还没用到)5、vim安装apt-get install zip unzip
6、sklearn安装sudo apt install vim
跑的时候发现会报错 No module named 'sklearn'
查看各个版本: 查看Linux版本:pip install scikit-learn
lsb_release -a
显示Ubuntu18.04.2 LTS
cuda版本查看:方法1: 查看文件
cat /usr/local/cuda/version.txt
方法2: 命令
nvcc --version
可以看到是cuda version 10.0.130
还有一种是
nvidia-smi.
这种是在查询GPU使用情况的同时查看最高可安装的cuda版本。
这里显示10.1,是说可以安装10.1.但是实际上安装的是10.0
CuDnn版本查看:cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
实际上没有反应,应该是没安装。为了以防万一
cd /usr/local/cuda
然后输入
ls
看看cuda文件夹下面有啥,发现只有个version.txt(里面是cuda版本)、include和其他乱七八糟没用的
继续到include
cd include
然后继续查看
ls
发现是一堆头文件,里面没有一个cudnn.h(如果装了cudnn,理论上肯定有cudnn.h)
所以确定没有。那么就安装!
CudNN的安装:先看下对应cuda10.0的cudnn版本
cuDNN Archive | NVIDIA Developer
然后cd到安装目录,解压(注意是tgz文件)
tar zxvf cudnn-10.0-linux-x64-v7.6.5.32.tgz
出现一个cuda文件夹,接下来主要把cuda/include/cudnn.h和cuda/lib64/libcudnn*复制到cuda10的对应文件夹里面!
sudo cp cuda/include/cudnn.h /usr/local/cuda-10.0/include/
sudo cp cuda/lib64/libcudnn* /usr/local/cuda-10.0/lib64/
---------------------------------------------------------------------------------------------------------------------------------
* 代表0个或者多个特殊字符
在shell中也代表任意字符,比如ls a*,就是列出所用a开头的文件.
---------------------------------------------------------------------------------------------------------------------------------
注意这里不是移动到usr/local/cuda。而是cuda-10.0文件夹(这里保险起见再看下path里添加的是哪个文件夹吧)
sudo gedit ~/.bashrc
结尾加一下(自己手动输入然后保存哈)
export CUDA_HOME=/usr/local/cuda
export PATH=$PATH:$CUDA_HOME/bin
export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
然后save后回过头去复制(还是先cd到刚刚cudnn解压的目录)
sudo cp cuda/include/cudnn.h /usr/local/cuda-10.0/include/
sudo cp cuda/lib64/libcudnn* /usr/local/cuda-10.0/lib64/
添加可执行权限(?)
sudo chmod +x /usr/local/cuda-10.0/include/cudnn.h
sudo chmod +x /usr/local/cuda-10.0/lib64/libcudnn*
接下去输入
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2、
显示
(我这里应该是7.6.5,找别人的图哈)
即成功!
Python版本切换实验室服务器的Ubuntu自带俩个版本的python 是python2(2.7)和python3(3.6.9),然而默认命令行的python都是指向python2.7.因此为了跑程序要改掉指向。让python->python3.6.9
首先
cd /usr/bin &&ll
确认下python的一些指向
然后依次输入
sudo rm python
sudo ln -s python3.6 python
然后输入python --version
显示3.6.9就成功
安装依赖库 1、pipsudo apt-get install python3-pip
然后
cd /usr/bin
ll pip*
可以看到实际上我们要调用pip3才行,有点麻烦,改下软链接。
sudo ln -s /usr/bin/pip3 /usr/bin/pip
接着再次查看
ll pip*
可以看到pip->pip3
那就可以用pip命令了。
2、pip换源默认pip下载的源来自国外,很慢,我们换成国内的清华源、豆瓣源等等
首先依次输入
mkdir ~/.pip
cd ~/.pip
touch pip.conf
vim pip.conf
然后按i键进入编辑模式
输入两行东西
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
然后再按一次ESC退出输入模式
然后输入
:wq
然后回车保存成功
3、opencv直接暴力下载
pip install opencv-python
报错
缺少一个模块
pip install scikit-build
重新
pip install opencv-python
又报错!
Collecting opencv-python
Using cached https://files.pythonhosted.org/packages/01/9b/be08992293fb21faf35ab98e06924d7407fcfca89d89c5de65442631556a/opencv-python-4.5.3.56.tar.gz
Collecting numpy>=1.13.3 (from opencv-python)
Using cached https://files.pythonhosted.org/packages/45/b2/6c7545bb7a38754d63048c7696804a0d947328125d81bf12beaa692c3ae3/numpy-1.19.5-cp36-cp36m-manylinux1_x86_64.whl
Building wheels for collected packages: opencv-python
Running setup.py bdist_wheel for opencv-python ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-pngogcn6/opencv-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpqrjtuw_5pip-wheel- --python-tag cp36:
Traceback (most recent call last):
File "/home/sunjiadong/.local/lib/python3.6/site-packages/skbuild/setuptools_wrap.py", line 560, in setup
cmkr = cmaker.CMaker(cmake_executable)
File "/home/sunjiadong/.local/lib/python3.6/site-packages/skbuild/cmaker.py", line 95, in __init__
self.cmake_version = get_cmake_version(self.cmake_executable)
File "/home/sunjiadong/.local/lib/python3.6/site-packages/skbuild/cmaker.py", line 82, in get_cmake_version
"Problem with the CMake installation, aborting build. CMake executable is %s" % cmake_executable)
Problem with the CMake installation, aborting build. CMake executable is cmake
----------------------------------------
Failed building wheel for opencv-python
Running setup.py clean for opencv-python
Failed to build opencv-python
Installing collected packages: numpy, opencv-python
Running setup.py install for opencv-python ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-pngogcn6/opencv-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-l1rn4gz_-record/install-record.txt --single-version-externally-managed --compile --user --prefix=:
Traceback (most recent call last):
File "/home/sunjiadong/.local/lib/python3.6/site-packages/skbuild/setuptools_wrap.py", line 560, in setup
cmkr = cmaker.CMaker(cmake_executable)
File "/home/sunjiadong/.local/lib/python3.6/site-packages/skbuild/cmaker.py", line 95, in __init__
self.cmake_version = get_cmake_version(self.cmake_executable)
File "/home/sunjiadong/.local/lib/python3.6/site-packages/skbuild/cmaker.py", line 82, in get_cmake_version
"Problem with the CMake installation, aborting build. CMake executable is %s" % cmake_executable)
Problem with the CMake installation, aborting build. CMake executable is cmake
----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-pngogcn6/opencv-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-l1rn4gz_-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-pngogcn6/opencv-python/
主要说是“Problem with the CMake installation, aborting build. CMake executable is cmake"
查了一下发现是pip版本太低。。。
sudo pip install --upgrade pip
然后第三次
pip install opencv-python
顺便把拓展库conrib也下了
pip install opencv-contrib-python
然后依次输入python
import cv2
import numpy
没报错就是成功
4、tensorflow下载tensorflow的版本跟cuda、cudnn关系很大,因此要去官网看看
https://www.tensorflow.org/install/source#common_installation_problems
拉到最下面看表格,记得科学上网
这里发现我们cuda10.0应该对应cudnn7.4+gcc7.3.1(通过gcc --version看了机子上是7.4.0)
然后可以下载1.15.0版本的,
因此
pip install tensorflow-gpu==1.15.0
记得要加-gpu 不然默认下载cpu的
5、tensorflow-plot和cython都是暴力下载
编译项目和跑项目pip install tensorflow-plot cython
根据官网一步步进行
记得先unzip哈
按照一步步搭配后(记得要改一些文件里的路径)
成功跑起来啦~之后遇到的Debug再说吧
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)