以下均在 Windows 10操作系统下进行。
我在conda中安装了pytorch1.4.0和cuda10.1(通过命令 conda install pytorch==1.4.0 torchvision==0.5.0 cudatoolkit=10.1
),命令可以在pytorch官网上找到。
随后又安装TensorFlow1.14(通过conda 安装不上,通过pip可以安装上,但是引入的时候报错), import tensorflow
时报错
importError: Could not find 'cudart64_100.dll'
所安装的TensorFlow版本和当前的cuda版本不匹配导致的。
更新pytorch和cuda版本,(通过命令 conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0
),在Pytorch官网上找的命令,然后再通过conda安装TensorFlow1.14( conda install tensorflow-gpu==1.14
)
问题得以解决!
- WARNING: tf.xxx is deprecated, Please use tf.compat.v1.xx insteaed
原因:官方只是想通知使用当前tensorflow版本的人,将来会发生什么,此警告可忽略。
解决方法:
import tensorflow as tf tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
- FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future ver...(特别多的FutureWarning信息)
原因:Numpy版本过高
解决方法:
安装低版本的Numpy即可。
pip install numpy==1.16.4
-
其他Warning:
import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2' #设置为1屏蔽一般信息,2屏蔽一般和警告,3屏蔽所有输出
import tensorflow as tf
-
pytorch查看cuda是否可用
import torch
print(torch.__version__)
print(torch.cuda.is_available())
- pytorch查看cuda是否可用
import tensorflow as tf
tf.test.is_gpu_available()
Original: https://blog.csdn.net/qq_38342468/article/details/122217995
Author: 岁寒良木
Title: 关于pytorch、TensorFlow、cuda版本匹配问题