记录使用Anaconda安装Python工具包的各种小坑~
装环境真是一生之敌!!!
Pycharm
Pycharm好像已经不支持Python 3.5版本, 导入虚拟环境编译器提示unsupported
参考链接: pycharm配置环境出现unsupported
Tensorflow
import tensorflow提示FutureWarning
安装各种包要注意版本兼容问题
D:\Anaconda3\envs\TensorFlow2.0\lib\site-packages\tensorflow\python\framework\dtypes.py:516: 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)])
D:\Anaconda3\envs\TensorFlow2.0\lib\site-packages\tensorflow\python\framework\dtypes.py:517: 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_quint8 = np.dtype([(“quint8”, np.uint8, 1)])
D:\Anaconda3\envs\TensorFlow2.0\lib\site-packages\tensorflow\python\framework\dtypes.py:518: 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_qint16 = np.dtype([(“qint16”, np.int16, 1)])
D:\Anaconda3\envs\TensorFlow2.0\lib\site-packages\tensorflow\python\framework\dtypes.py:519: 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_quint16 = np.dtype([(“quint16”, np.uint16, 1)])
D:\Anaconda3\envs\TensorFlow2.0\lib\site-packages\tensorflow\python\framework\dtypes.py:520: 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_qint32 = np.dtype([(“qint32”, np.int32, 1)])
D:\Anaconda3\envs\TensorFlow2.0\lib\site-packages\tensorflow\python\framework\dtypes.py:525: 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_resource = np.dtype([(“resource”, np.ubyte, 1)])
D:\Anaconda3\envs\TensorFlow2.0\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:541: 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)])
D:\Anaconda3\envs\TensorFlow2.0\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:542: 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_quint8 = np.dtype([(“quint8”, np.uint8, 1)])
D:\Anaconda3\envs\TensorFlow2.0\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:543: 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_qint16 = np.dtype([(“qint16”, np.int16, 1)])
D:\Anaconda3\envs\TensorFlow2.0\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:544: 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_quint16 = np.dtype([(“quint16”, np.uint16, 1)])
D:\Anaconda3\envs\TensorFlow2.0\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:545: 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_qint32 = np.dtype([(“qint32”, np.int32, 1)])
D:\Anaconda3\envs\TensorFlow2.0\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:550: 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_resource = np.dtype([(“resource”, np.ubyte, 1)])
两种解决方法:
- 重新安装匹配版本
参考链接:tensorflow与numpy的版本兼容性问题
评论里一些可行的匹配版本
Tensorflow | Numpy |
---|---|
1.14.0 | 1.16.0/1.15.0 |
1.9.0 | 1.14.0 |
1.12.0 | 1.16.0 |
1.1.0 | 1.12.1 |
- 根据错误信息修改代码
参考链接:envs\TensorFlow2.0\lib\site-packages\tensorflow\python\framework\dtypes.py:516: FutureWarning 解决方案
TFlearn
import tflearn提示ModuleNotFoundError
>>> import tflearn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Olive\anaconda3\envs\tensorflow\lib\site-packages\tflearn\__init__.py", line 4, in <module>
import tensorflow.compat.v1 as tf
ModuleNotFoundError: No module named 'tensorflow.compat'
版本不兼容问题,tensorflow用的是1.4的版本,重新安装tflearn
pip install tflearn==0.3.2
import tflearn提示curses is not supported on this machine
>>> import tflearn
curses is not supported on this machine (please install/reinstall curses for an optimal experience)
下载包文件curses‑2.2‑cp36‑cp36m‑win_amd64.whl。
然后,在文件所在目录执行命令pip install curses‑2.2‑cp36‑cp36m‑win_amd64.whl
注意自己使用的Python版本匹配
参考链接:hdf5、curses is not supported on this machine(已解决)
Jupyter Notebook
直接使用conda install
总报各种错误,直接在Anaconda Navigator里进行安装
-
选择要安装的虚拟环境
-
点击
Install
等待安装… -
点击
Launch
其他一些小问题:
Jupyter notebook 一直在启动内核的解决方法
安装jupyter出现ipython与prompt-toolkit要求版本不一致的问题
Tensorflow-gpu
小破电脑也搞了个GPU加速嘻嘻~
亲测可行版本:
Python 3.6 + cuda 10.0 + cuDNN 7.4.2 + tensorflow-gpu 1.14.0 + numpy 1.16.4
安装过程参考链接:
【CUDA】win10切换不同版本的CUDA 修改完记得重启!
tensorflow2.0GPU版本的环境配置与安装教程
安装过程都是差不多的,主要是要注意版本间的匹配问题。
官方版本参考 一直拉到最下面~
注:
- cuda 10.0 下载地址
- cuDNN 7.4.2 下载地址 在列表里找到需要的对应版本~
pip install tensorflow_gpu==1.14.0
- 提示
FutureWarning
,可以重新安装numpypip install numpy==1.16.4
测试代码
输入
>>> from tensorflow.python.client import device_lib
>>> print(device_lib.list_local_devices())
2021-04-01 14:52:34.184694: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1640] Found device 0 with properties:
name: GeForce MX150 major: 6 minor: 1 memoryClockRate(GHz): 1.0375
pciBusID: 0000:01:00.0
2021-04-01 14:52:34.193477: I tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU libraries are statically linked, skip dlopen check.
2021-04-01 14:52:34.200112: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1763] Adding visible gpu devices: 0
2021-04-01 14:52:34.204943: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1181] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-04-01 14:52:34.210447: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1187] 0
2021-04-01 14:52:34.214914: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1200] 0: N
2021-04-01 14:52:34.333901: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1326] Created TensorFlow device (/device:GPU:0 with 1360 MB memory) -> physical GPU (device: 0, name: GeForce MX150, pci bus id: 0000:01:00.0, compute capability: 6.1)
[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 4848747427945476852
, name: "/device:GPU:0"
device_type: "GPU"
memory_limit: 1426918195
locality {
bus_id: 1
links {
}
}
incarnation: 2276643946330021579
physical_device_desc: "device: 0, name: GeForce MX150, pci bus id: 0000:01:00.0, compute capability: 6.1"
]
或者输入
>>> import tensorflow as tf
>>> tf.test.is_gpu_available()
2021-04-01 14:43:26.043637: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2021-04-01 14:43:26.056345: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library nvcuda.dll
2021-04-01 14:43:26.792655: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1640] Found device 0 with properties:
name: GeForce MX150 major: 6 minor: 1 memoryClockRate(GHz): 1.0375
pciBusID: 0000:01:00.0
2021-04-01 14:43:26.803571: I tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU libraries are statically linked, skip dlopen check.
2021-04-01 14:43:26.810279: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1763] Adding visible gpu devices: 0
2021-04-01 14:43:27.776118: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1181] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-04-01 14:43:27.783607: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1187] 0
2021-04-01 14:43:27.788662: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1200] 0: N
2021-04-01 14:43:27.793170: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1326] Created TensorFlow device (/device:GPU:0 with 1360 MB memory) -> physical GPU (device: 0, name: GeForce MX150, pci bus id: 0000:01:00.0, compute capability: 6.1)
True
得到这样的结果应该就OK啦~