记性不好+重装系统当饭吃,记录一下常用的装机命令行。
环境:Ubuntu16.04,Anaconda3
创建虚拟环境:
conda create -n env_name python=3.6
激活虚拟环境:
source activate env_name
退出虚拟环境:
source deactivate env_name
删除虚拟环境:
conda remove -n env_name --all
添加conda国内镜像:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes
安装cuda 8.0:
conda install cudatoolkit=8.0 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64/
安装cudnn7.0:
conda install cudnn=7.0.5 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64/
安装tensorflow-gpu,使用conda安装tensorflow可以不用提前安装cuda和cudnn,直接一行命令全下载:
conda install tensorflow-gpu=1.4.1
装好以后,看一下有没有安装成功:
python
import tensorflow as tf
sess=tf.Session(config=tf.ConfigProto(log_device_placement=True))
如果输出了gpu信息,就算安装成功了。
安装opencv3,之前想再官网上面下载opencv3.3,但是一直下不下来,搜了一下也没看到别人用conda下载,自己试了一下,发现完全ok,自动下载依赖包:
conda install opencv
下载好以后 import cv2 看看成不成功。
还有另一种安装cuda+cudnn的方法,比较复杂,之前花了很长时间成功安装过一次。暂时还不知道两种方法安装在使用中有什么区别。
使用conda安装cuda和cudnn后,无法按照一般的方法比如 nvcc -v 来检验是否成功,但是使用 conda list 可以在里面找到,在python中调用gpu会显示成功。具体的区别还没有找到。
最近在配置openpose的环境,使用的是conda安装,看看到时候能不能成功再来补坑。(已经做好了重装系统的准备