Of course I'll use the gpu for training, it's faster.
I tried to run it with the cpu version of tensorflow and it reported an error, which is not very easy to read.
Probably means that some nodes were not found.
I later found out why, the pb models saved with gpu and cpu are not quite the same, but the checkpoints file is common.
Use tensorflow-cpu to reconvert the checkpoints file to a pb file again and you're done.
Perfect solution!
Addendum: tensflow-gpu version of the myriad of pit pits! (tf pit big summary)
My own small notebook with pycharm+win10+anaconda3+python3 pre-installed.
2019/3/24 reinstallation found: currently CUDA10.1 can not install tensorflow1.13, change CUDA to 10.0 can be (remember the corresponding cudann ah)
If you're just starting out, it's recommended that you use tensorflw to learn how to run a few demos first, and then when you can't accept the turtle-like speed of the cpu, you'll have to start trying to get the gpu to run it.
The cpu running tensorflow only needs to be downloaded at anaconda3.
Installation of tensorflow for cpu running.
My little book is currently on the gpu version, the one in the red circle under cpu version is fine!
Once it's installed type directly into the python command
import tensorflow as tf
If no error is reported the call was successful.
See whether tensorflow is currently running on a cpu or gpu call:
import tensorflow as tf import numpy as np a = ([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a') b = ([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b') c = (a, b) sess = (config=(log_device_placement=True)) print((c))
Then paste this code into the compiler and run it.
Look at what the call runs in the results of the run
Depending on whether a gpu or cpu is given you can tell which one is currently running
Install the gpu version of tensorflow.
The first step is to make sure your video card is an N-card.
Then go on /cuda-gpus to see if your graphics card is allowed by NVDIA to run machine learning
For CUDA with cudann installation:
You need to go to nvdia to download CUDA and cudann, the most important thing here is to pay attention to the matching of CUDA and cudann with tensorflow.
Note the matching of versions!!!
Note the matching of versions!!!
Note the matching of versions!!!
tensorflow doesn't support CUDA above 9.0 until after version 1.5, so if the CUDA version is too high, it will cause a file not found error.
You can also see CUDA paired with cudann on the official website
After installing cudann, you need to copy its three files to the CUDA directory and add three new paths:
3 paths.
When using the gpu version of tf, it is no longer necessary to install the original version of tf, just uninstall it and install the tf-gpu version.
To determine if you have the tf package installed, for pycharm users, you can look at the setting to see if you have tf-gpu installed.
The environment I use is: tf1.2+CUDA8.0+cudann5.1
When all properly installed
import tensorflow as tf It's still wrong.
Problems with cudnn64_6.dll
About importing TensorFlow can not find cudnn64_6.dll, in fact, the download is cudnn64_7.dll (the version does not match), modify it over the line.
The directory is under: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin
For the constant attempts to throw fail to run the GPU version, you can delete the tf first and re-download the
import tensorflow as tf print(tf.__version__)
Query the tensorflow installation path as.
print(tf.__path__)
Successfully running with GPU but still reporting errors when running my own code:
If the reason for the error is this
ResourceExhaustedError (see above for traceback): OOM when allocating tensor with shape[10000,28,28,32]
The last thing about this error is that the GPU doesn't have enough memory, at this point you can take a look at your code and see if you're loading too much of the training set or too much of the test set, and just load it one part at a time.
For the training setbanch_xs,banch_ys = .next_batch(1000)
change into
banch_xs,banch_ys = .next_batch(100)
That's it.
And the test set?print(compute_accuracy([:5000], [:5000]))
change into
print(compute_accuracy(, ))
can immediately (do sth)
The above is a personal experience, I hope it can give you a reference, and I hope you can support me more. If there is any mistake or something that has not been fully considered, please do not hesitate to give me advice.