Ubuntu16.04配置各类深度学习框架方法

 

安装前提:

如果装cpu版本pytorch没有问题(caffe我没有试过)

安装gpu版本需提前安装好nvidia显卡驱动,cuda和cuDNN

测试:nvidia-smi

nvcc -V

一、pytorch

简单,明了

https://pytorch.org/get-started/locally/

选一下命令行一复制ok

二、caffe2

现在caffe2已经集成在pytorch中了

首先安装caffe2需要的环境

https://caffe2.ai/docs/getting-started.html?platform=ubuntu&configuration=compile

Building for source-install dependence

然后安装pytorch就可以了

测试方法:

# To check if Caffe2 build was successful
python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"

# To check if Caffe2 GPU build was successful
# This must print a number > 0 in order to use Detectron
python -c 'from caffe2.python import workspace; print(workspace.NumCudaDevices())'

三、tensorflow

pip install tensorflow-gpu==1.11.0

注意:如果numpy版本为1.17.0会导致import tensorflow报错

(tensorflow) lxy@mat:~/python/tensorflow/bin$ python
Python 3.5.2 (default, Nov 12 2018, 13:43:14) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
/home/lxy/python/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:523: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
/home/lxy/python/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:524: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
将版本降为1.16.0即可。

测试GPU资源是否可用:

tf.test.is_gpu_available()

你可能感兴趣的:(Linux)