Windows 10 安装 Cuda, Tensorflow, 和keras,附CPU/GPU切换小技巧
来源:互联网 发布:淘宝打折软件哪个好用 编辑:程序博客网 时间:2024/05/21 14:50
Originally published on Medium, reblogged in case of blocking
I’ve tried months ago to install the GPU-based Machine learning framework, namely keras with tensorflow, but get stuck following the official indication of the latter, and the issue remained unresolved until yesterday because of loads of patients in summer vocation, and I finally managed to get m1000m working.
I basically followed instructions written in Chinese in http://blog.csdn.net/u012898521/article/details/69611800, with a few modifications according to keras documentation in Chinese HERE, and actually I did a combination of both.
Step 1 — python
By far tensorflow only support python 3 but no newer than major version of 3.5, and last time I got a lot of trouble tried to install the dependencies especially scipy. I didn’t use anaconda because it starts rather slow and Google said you could install tensorflow without it, and it was later I found scipy itself WILL encounter problems when installed on windows.
SO, just install Anaconda with python 3.5 (I installed Anaconda 4.2.0 with python 3.5.2) HERE, and it will save you all the troubles.
Step 2 — CUDA and CuDNN
CUDA is toolkit enables you to all the fun programming with NVIDIA GPU, you’re welcomed unless your GPU is prior to GTX 5XX.
You can download it HERE, and you’ll find it a bit of time consuming.
Installation is simple a series of ‘Next’s.
And now you can install CuDNN, an acceleration library for CUDA. You’ll require to signed a developer account in order to get it HERE, and then unzip the folders and overwrite folders atC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\8.0
with same names.
Step 3 — Tensorflow
Simply use pip with installation.
To install CPU version(required)
>pip install tensorflow
To install GPU version(optional)
>pip install tensorflow-gpu
If it says pip is outdated or cannot find resource,try upgrading pip
python.exe -m pip install — upgrade pip
Then, test with import and it should not return any errors
>python>>>import tensorflow as tf
Step 4 — Keras
A line of code will do
pip install keras
Keras will be installed with theano by default, but it will use tensorflow as the back-end, so don’t panic, and test if keras is installed correctly by
import keras
Now we could run the MNIST example in Keras with either CPU or GPU
Step 4 — Run and switch between CPU and GPU
Download keras testing data sets HERE, or if you have git run
git clone https://github.com/fchollet/keras.git
Locate at keras/examples/
, and run mnist_mlp.py
, if you installed CUDA and CuDNN correctly, it will run on GPU by default, and here’s my running on GPU:
Sadly I have only a M1000M on a laptop, whose performance is compromised. ��
If you want to know how it will be on using CPU, you may Googled and get a suggestion os.environ["CUDA_VISIBLE_DEVICES"] =""
, which you may well find vitiate.
And here’s the trick, simply change the value to -1 will do. More specifically, add these two lines whenever you want to run it on CPU:
import osos.environ[“CUDA_VISIBLE_DEVICES”] = ‘-1’
My i7–6850HQ runs two times slower than the ‘weak’ GPU M1000M
Finally, we have GPU based computer��
- Windows 10 安装 Cuda, Tensorflow, 和keras,附CPU/GPU切换小技巧
- Windows安装TensorFlow(CPU/GPU)
- Win7/Win10环境安装:Cuda+keras+tensorflow-gpu
- windows安装tensorflow和keras
- 170819 Anaconda两行命令安装tensorflow-gpu+keras-gpu及Gpu vs Cpu验证
- Ubuntu 安装 tensorflow-gpu + keras
- windows下安装gpu版本的keras\tensorflow
- Keras以及Tensorflow强制使用CPU,GPU
- ubuntu 16.04 安装Tensorflow(CPU和GPU)
- Windows 7(10) 下安装 tensorflow,theano,keras并使用GPU加速。
- windows 10 64bit下安装Tensorflow+Keras+VS2015+CUDA8.0 GPU加速
- 【TensorFlow】Windows+Anaconda3+Tensorflow(CPU&GPU)+Pycharm 安装
- Keras下GPU/CPU模式切换
- Keras下GPU/CPU模式切换
- Keras下GPU/CPU模式切换
- 在Keras中将cpu切换为gpu
- 双显卡 ubuntu16.04 安装 NVIDIA驱动 + CUDA + cuDNN + tensorflow-gpu + keras
- 用GPU加速深度学习: Windows安装CUDA+TensorFlow教程
- hdu1394
- spring的事务控制
- Http请求头和响应头
- Python3批量移动指定文件到指定文件夹
- 信用卡评分模型优化
- Windows 10 安装 Cuda, Tensorflow, 和keras,附CPU/GPU切换小技巧
- Android26-ContentProvider
- tyvj1463 智商问题
- js 函数,方法总结
- 三目运算嵌套求三个数最大值及顺序选择结构-c基础第五课
- 用SpringBoot 做代web理服务器
- 实验五 I/O 模型网络程序实验
- java-DateDemo
- hdu 1595 BFS 记录边+SPFA