在anaconda中创建虚拟环境
conda create --name tf_gpu_env2 python=3.6
查看所有的虚拟环境
conda info --envs
连接环境
source activate tf_gpu_env2
关闭环境
source deactivate
查看tensorflow各个版本:(查看会发现有一大堆TensorFlow源,但是不能随便选,选择可以用查找命令定位)
anaconda search -t conda tensorflow-gpu
查看tensorflow版本信息
anaconda show anaconda/tensorflow-gpu
安装指定版本
conda install --channel https://conda.anaconda.org/anaconda tensorflow-gpu=1.12.0
错误1:
Traceback (most recent call last):
File “setup.py”, line 4, in
from Cython.Build import cythonize
ModuleNotFoundError: No module named 'Cython’
mv: cannot stat ‘build//.so’: No such file or directory
解决方法:在虚拟环境中 python -m pip install cython
错误2:
Traceback (most recent call last):
File “./main/demo.py”, line 7, in
import cv2
ModuleNotFoundError: No module named 'cv2’
解决方法:pip install opencv-python
错误3(警告?)
/home/cheoywoo/anaconda3/envs/tf_gpu_env2/lib/python3.6/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/cheoywoo/anaconda3/envs/tf_gpu_env2/lib/python3.6/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’.
numpy1-17-0版本过高,使用numpy-1.16-0