一,anancona 安装
https://repo.anaconda.com/archive/
conda create -n caffe_gpu -c defaults python=3.6 caffe-gpu
conda create -n caffe -c defaults python=3.6 caffe
测试:
import caffe
python -c "import caffe; print dir(caffe)"
参考:https://blog.csdn.net/weixin_37251044/article/details/79763858
一、编译Caffe、PyCaffe URL : https://github.com/BVLC/caffe.git 1 1.下载Caffe git clone https://github.com/BVLC/caffe.git cd caffe 注意:如果想在anaconda下使用,就先 source activate caffe_env 然后在这个环境下安装 利用anaconda2随意切换proto的版本,多proto并存,protobuf,libprotobuf 2.编译caffe 用cmake默认配置: [注意]:一般需要修改config文件。 进入caffe根目录 mkdir build cd build cmake .. make all -j8 make install make runtest -j8 3.安装pycaffe需要的依赖包,并编译pycaffe cd ../python conda install cython scikit-image ipython h5py nose pandas protobuf pyyaml jupyter for req in $(cat requirements.txt); do pip install $req; done cd ../build make pycaffe -j8 4.添加pycaffe的环境变量 终端输入如下指令: vim ~/.bashrc 在最后一行添加caffe的python路径(到达vim最后一行快捷键:Shift+G): export PYTHONPATH=/path/to/caffe/python:$PYTHONPATH 注意: /path/to/caffe是下载的Caffe的根目录,例如我的路径为:/home/Jack-Cui/caffe-master/python Source环境变量,在终端执行如下命令: source ~/.bashrc 注意: Source完环境变量,会退出testcaffe这个conda环境,再次使用命令进入即可。 四、测试 执行如下命令: python -c "import caffe; print dir(caffe)" fatal error: pyconfig.h: No such file or directory 如果使用的是系统的python路径,解决方法如下: make clean export CPLUS_INCLUDE_PATH=/usr/include/python2.7 make all -j8 如果使用的是anaconda Python,路径如下: export CPLUS_INCLUDE_PATH=/home/gpf/anaconda3/include/python3.6m http://blog.csdn.net/GPFYCF521/article/details/80387869 cd /usr/local/src/caffe-master/ 2 ll 3 make pycaffe 4 find / -name "Python.h" 5 export CPLUS_INCLUDE_PATH=/usr/local/src/Python-3.6.4/Include/Python.h:$CPLUS_INCLUDE_PATH 6 make clean 7 make pycaffe 8 export CPLUS_INCLUDE_PATH=/usr/local/src/Python-3.6.4/Include/:$CPLUS_INCLUDE_PATH 9 make clean 10 make pycaffe 11 export CPLUS_INCLUDE_PATH= 12 export CPLUS_INCLUDE_PATH=/usr/local/src/Python-3.6.4/Include/:$CPLUS_INCLUDE_PATH 13 make clean 14 make pycaffe 15 find / -name "pyconfig.h" 16 yum install python-devel.x86_64 17 make clean 18 make pycaffe 19 find python3.6 20 locate python3.6 21 make clean 22 export CPLUS_INCLUDE_PATH=/usr/include/python2.7 23 export CPLUS_INCLUDE_PATH= 24 export CPLUS_INCLUDE_PATH=/root/anaconda3/include/python3.5m 25 make all 26 find / -name "pycaffe" 27 history 装的是python3.6,项目中用到boost相关代码,编译时找不到pyconfig.h。看了一下/usr/include/python3.6和/usr/include/python3.6m,都只有一个pyconfig-64.h文件。 网上查了一圈,找了各种方法都搞不定,其中一种方法可以安装一堆.h进/usr/include/python2.7,3.6文件夹中还是没有。方法如下: 1. 可以先查看一下含python-devel的包 yum search python | grep python-devel 2. 64位安装python-devel.x86_64,32位安装python-devel.i686,我这里安装: sudo yum install python-devel.x86_64 yum search python | grep python36 python36u-devel.x86_64 : Libraries and header files needed for Python yum install python36u-devel.x86_64 conda create -n caffe_gpu -c defaults python=3.5 caffe-gpu conda create -n caffe -c defaults python=3.5 caffe CONDA 安裝caffe 一、编译Caffe、PyCaffe URL : https://github.com/BVLC/caffe.git 1 1.下载Caffe git clone https://github.com/BVLC/caffe.git cd caffe 注意:如果想在anaconda下使用,就先 source activate caffe_env 然后在这个环境下安装 利用anaconda2随意切换proto的版本,多proto并存,protobuf,libprotobuf 2.编译caffe 用cmake默认配置: 1 [注意]:一般需要修改config文件。 进入caffe根目录 mkdir build cd build cmake .. make all -j8 make install make runtest -j8 3.安装pycaffe需要的依赖包,并编译pycaffe cd ../python conda install cython scikit-image ipython h5py nose pandas protobuf pyyaml jupyter for req in $(cat requirements.txt); do pip install $req; done cd ../build make pycaffe -j8 4.添加pycaffe的环境变量 终端输入如下指令: 1 vim ~/.bashrc 1 在最后一行添加caffe的python路径(到达vim最后一行快捷键:Shift+G): 1 export PYTHONPATH=/path/to/caffe/python:$PYTHONPATH 1 2 注意: /path/to/caffe是下载的Caffe的根目录,例如我的路径为:/home/Jack-Cui/caffe-master/python Source环境变量,在终端执行如下命令: 1 source ~/.bashrc 1 注意: Source完环境变量,会退出testcaffe这个conda环境,再次使用命令进入即可。 四、测试 执行如下命令: 1 python -c "import caffe; print dir(caffe)" 1 2 输出结果如下: 从上图可以看出,caffe编译通过,并且一些的python的caffe接口,也存在。 注意: 如果创建了conda环境,每次想要使用caffe,需要先进入这个创建的conda环境。 export PATH=/root/anaconda3/bin:$PATH conda create -n caffe -c defaults python=3.5 conda install caffe-gpu conda install tensorflow-gpu==1.11.0 conda create --name tensorflow python=3.5 source activate tensorflow source deactivate conda remove -n tensorflow --all import tensorflow as tf 和 tf.__version__ 您正在使用GPU版本。您可以列出可用的tensorflow设备 from tensorflow.python.client import device_lib print(device_lib.list_local_devices()) 1. conda env list 或 conda info -e 查看当前存在哪些虚拟环境 2. conda update conda 检查更新当前conda 3. conda update --all 更新本地已安装的包 4. conda create -n your_env_name python=X.X(2.7、3.6等) anaconda 命令创建python版本为X.X、名字为your_env_name的虚拟环境。your_env_name文件可以在Anaconda安装目录envs文件下找到。 5. Windows: activate your_env_name(虚拟环境名称) 激活虚拟环境 6. conda install -n your_env_name [package] 安装package到your_env_name中 7. linux: source deactivate Windows: deactivate 关闭虚拟环境 8. conda remove -n your_env_name(虚拟环境名称) --all 删除虚拟环境 9. conda remove --name your_env_name package_name 删除环境中的某个 conda 安装pytorch conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/ 添加清华源 命令行中直接使用以下命令 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/conda-forge conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/ # 设置搜索时显示通道地址 conda config --set show_channel_urls yes ———————————————————————————————————————————————————————————————————————————————— 设置搜索时显示通道地址 | conda config --set show_channel_urls yes conda GPU的命令如图所示: conda install pytorch torchvision -c pytorch conda CPU的命令如图所示: conda install pytorch-cpu -c pytorch pip3 install torchvision pytorch-gpu conda install pytorch torchvision cudatoolkit=9.0 -c pytorch import torch print(torch.__version__) print(torch.cuda.device_count()) print(torch.cuda.is_available()) --------------------------------------------------------------------------------| 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/conda-forge/ conda config --set show_channel_urls yes 查看已经添加的channels conda config --get channels 已添加的channel在哪里查看 vim ~/.condarc conda search gatk 安装完成后,可以用“which 软件名”来查看该软件安装的位置: which gatk 如需要安装特定的版本: conda install 软件名=版本号 conda install gatk=3.7 查看已安装软件: conda list 更新指定软件: conda update gatk 卸载指定软件: conda remove gatk cntk https://blog.csdn.net/Jonms/article/details/79550512 ubuntu1604 cuda -cudnn 接着,运行下面的命令安装anaconda $ sh Anaconda3-5.1.0-Linux-x86_64.sh anaconda的安装很简单,这里就不多描述。 CNTK需要你的系统安装有OpenMPI。在Ubuntu中可以通过以下命令安装 $ sudo apt install openmpi-bin 然后,创建名为cntk-py35的虚拟环境 $ conda create --name cntk-py35 python=3.5 numpy scipy h5py jupyter 激活cntk虚拟环境 $ source activate cntk-py35 关闭cntk虚拟环境 $ source deactivate 激活虚拟环境后,用pip安装CNTK(GPU)即可 $ pip install https://cntk.ai/PythonWheel/GPU/cntk-2.4-cp35-cp35m-linux_x86_64.whl 测试CNTK是否安装成功并输出CNTK版本 $ python -c "import cntk; print(cntk.__version__)" cpu pip install https://cntk.ai/PythonWheel/CPU-Only/cntk-2.7.post1-cp35-cp35m-linux_x86_64.whl python -c "import cntk; print(cntk.__version__)" 报错: ImportError: No module named 'cntk._cntk_py' ImportError: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory 处理: find / -name "libpython3.5m.so.1.0" 找到路径 使用conda安装的 /root/anaconda3/envs/cntk-py35/lib/ 加入环境变量 #cd /etc/ld.so.conf.d #vim python3.conf 将编译后的python/lib地址加入conf文件 #ldconfig 容器环境变量会丢失,使用dockerfile重新赋值。 export PATH=/root/anaconda3/bin:$PATH 上面的链接库配置 pip https://cntk.ai/PythonWheel/CPU-Only/cntk-2.7.post1-cp36-cp36m-linux_x86_64.whl python3.7环境下 theano apt-get install python-numpy python-scipy python-dev python-pip python-nose g++ libopenblas-dev pip install Theano NumPy (~30s): python -c "import numpy; numpy.test()" SciPy (~1m): python -c "import scipy; scipy.test()" Theano (~30m): python -c "import theano; theano.test()" 已安装cuda export PATH=/usr/local/cuda-5.5/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda-5.5/lib64:$LD_LIBRARY_PATH 安装Caffe2 docker pull caffe2ai/caffe2 # to test nvidia-docker run -it caffe2ai/caffe2:latest python -m caffe2.python.operator_test.relu_op_test # to interact nvidia-docker run -it caffe2ai/caffe2:latest /bin/bash python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure" #返回Success就OK python2 -c 'from caffe2.python import workspace; print(workspace.NumCudaDevices())' #返回1就OK #进入python输入 from caffe2.python import workspace 错误: ModuleNotFoundError: No module named 'google' pip install protobuf ModuleNotFoundError: No module named 'past' pip install future 安装后检测 python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure" gpu检测 python -m caffe2.python.operator_test.relu_op_test Python2.7和Python3.6下都可以,不过只是cpu版本,只限于Mac和Ubuntu平台下: conda install -c caffe2 caffe2 参考网址: https://blog.csdn.net/qq_35451572/article/details/79428167 https://blog.csdn.net/Yan_Joy/article/details/70241319 https://blog.csdn.net/zmm__/article/details/90285887 https://blog.csdn.net/u013842516/article/details/80604409 使用Docker安装GPU版本caffe2 https://blog.csdn.net/Andrwin/article/details/94736930 caffe安装 https://blog.csdn.net/jacky_ponder/article/details/53129355