Anaconda/conda 作为包管理工具:
假设你已经在你的机器上安装了 anaconda/conda,如果没有按照这个 - https://docs.anaconda.com/anaconda/install/windows/
conda create --name tensorflow_optimized python=3.7
conda activate tensorflow_optimized
# you need intel's tensorflow version that's optimized to use SSE4.1 SSE4.2 AVX AVX2 FMA
conda install tensorflow-mkl -c anaconda
#run this to check if the installed version is using MKL,
#which in turns uses all the optimizations that your system provide.
python -c "import tensorflow as tf; tf.test.is_gpu_available(cuda_only=False, min_cuda_compute_capability=None)"
# you should see something like this as the output.
2020-07-14 19:19:43.059486: I tensorflow/core/platform/cpu_feature_guard.cc:145] This TensorFlow binary is optimized with Intel(R) MKL-DNN to use the following CPU instructions in performance critical operations: SSE4.1 SSE4.2 AVX AVX2 FMA
To enable them in non-MKL-DNN operations, rebuild TensorFlow with the appropriate compiler flags.
pip3 作为包管理工具:
py -m venv tensorflow_optimized
.\tensorflow_optimized\Scripts\activate
#once the env is activated, you need intel's tensorflow version
#that's optimized to use SSE4.1 SSE4.2 AVX AVX2 FMA
pip install intel-tensorflow
#run this to check if the installed version is using MKL,
#which in turns uses all the optimizations that your system provide.
py -c "import tensorflow as tf; tf.test.is_gpu_available(cuda_only=False, min_cuda_compute_capability=None)"
# you should see something like this as the output.
2020-07-14 19:19:43.059486: I tensorflow/core/platform/cpu_feature_guard.cc:145] This TensorFlow binary is optimized with Intel(R) MKL-DNN to use the following CPU instructions in performance critical operations: SSE4.1 SSE4.2 AVX AVX2 FMA
To enable them in non-MKL-DNN operations, rebuild TensorFlow with the appropriate compiler flags.
一旦你有了这个,你就可以在pycharm中设置使用这个环境了。
在此之前,运行
Windows 上的where python,Linux 和 Mac 上的which python 当环境被激活时,应该为您提供解释器的路径。在 Pycharm 中,
转到首选项->项目:您的项目名称->项目解释器->单击设置符号->单击添加。
选择系统解释器->点击...->这将打开一个弹出窗口,询问python解释器的位置。
在位置路径中,粘贴来自where python的路径->点击确定
现在您应该看到安装在该环境中的所有软件包。
从下一次开始,如果您想为您的项目选择该解释器,请单击右下半部分显示 python3/python2(您的解释器名称)并选择您需要的解释器。
我建议你安装 Anaconda 作为你的默认包管理器,因为它可以让你在 Windows 机器上的 Python 开发生活更轻松,但你也可以使用 pip。