Installation of autokeras under win10
Install according to the method on the official website. Note: Auto-Keras only supports Python3.6.
Project github: https://github.com/jhfjhfj1/autokeras
pip install autokeras
Autokeras requires many dependencies, including tensorflow, pytorch, keras, numpy, etc. Most of them can be downloaded automatically after installing autokeras with pip, except for pytorch, which needs to be manually installed by referring to torch official website. Overall, it's pretty simple.
GPU usage of autokeras under win10
After the installation is complete, you can use the https://github.com/jhfjhfj1/autokeras/blob/master/examples/mnist.py file for testing:
from keras.datasets import mnist
from autokeras import ImageClassifier
import tensorflow
if __name__ == '__main__':
(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train = x_train.reshape(x_train.shape + (1,))
x_test = x_test.reshape(x_test.shape + (1,))
clf = ImageClassifier(verbose=True)
clf.fit(x_train, y_train, time_limit=12 * 60 * 60)
clf.final_fit(x_train, y_train, x_test, y_test, retrain=True)
y = clf.evaluate(x_test, y_test)
print(y * 100)
After running, a line of garbled characters is output, and the program can run normally, but when nvidia-smi is run in cmd, it is found that the GPU is not running, and the program runs dry on the CPU.
This is caused by the use of the command 'grep' in Linux in the get_device() function in the utils.py file under autokeras. Modify it to the batch command of win10:
//原utils.py下第80行
smi_out = os.popen('nvidia-smi -q -d Memory |grep -A4 GPU|grep Free >tmp').read()
//修改为
smi_out = os.popen('nvidia-smi -q -d Memory | findstr Free').read()
Run the test program again, no garbled output, check nvidia-smi, it can be seen that the GPU is running.
How to change the batch size in autokeras
Open the constant.py file under autokeras.
It can be seen that the default MAX_BATCH_SIZE = 128, directly modify MAX_BATCH_SIZE to deal with the problem of exceeding the video memory.