一、gpu检查
查看是否安装cuda:nvcc -V
然后放弃:度娘后发现CUDA8.0 不支持tensorflow 1.5,故需要降低版本。(也可提升CUDA版本,不过需要注意CUDA与cudnn版本的对应,以及是否与电脑的GPU兼容,否则很容易入坑。cuda8对应 cudnn6,cuda9 对应cudnn7.)
二、创建虚拟环境:
conda create -n tf2 python=3.6
三、更新pip
pip install pip -U # 升级 pip 到最新的版本 (>=10.0.0) 后进行配置
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple //使用清华源
四、安装tensoflow2.0
安装方法一:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn tensorflow==2.0
报错:
原因:(setuptools 版本太旧 , wrapt 不能卸载)
强制安装:pip install --ignore-installed -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn tensorflow==2.0
安装方法二:(我没安装成功,会报错)
python -m pip install --user --upgrade pip
pip install tensorflow==2.0.0-alpha0
执行import tensorflow报错:ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
解决:pip install --user --upgrade numpy
执行import tensorflow报错:TypeError: __init__() got an unexpected keyword argument 'serialized_options'