My PC is with AMD Ryzen 5 3600X, with 6 cores, no GPU. I trained my tabular regression in colab and I’m running the trained model in my pc. And it is slow. What make it even slower is the fact I found that it only use about 1/20 of the total CPU time. My code is like following:
for i in range(cnt):
print("learner ", i , " : ", process_time() - start, time()-start1)
res.append(learn_opt[i].get_preds()
Hi jerron hope all is well!
You will have to search for possible bottlenecks in all of your system that is used to produce this line of code.
res.append(learn_opt[i].get_preds()
e.g. which part of your system is actually causing the delay, if it is disk access time trying to improve CPU utility won’t make a difference, changing from a slow hard disk to an ssd or running all the code in ram would make a difference.
The links below show two possible approaches to speeding up your code.
The learner is a fastai.tabular.tabular_learner. There should be no I/O bottleneck, purely calculation in memory, because I didn’t see any increased disk or network activities change in the Performance monitor from the Task Manager. When the calculation started, the CPU level increased to 25% from 10%%, memory increased to 45% from 40%, disk stayed at 0% or 1%, network stayed the same.
As @s.s.o change your used batch size. Use as large of one as your CPU can handle, this is how you use more. Tabular NN’s are tiny so you can send them large amounts of data with only a small overhead, especially on inference since we’re not storing gradients
I tried res.append(learn_opt[i].get_preds(ds_type=DatasetType.Valid,n_batch=100)) and res.append(learn_opt[i].get_preds(ds_type=DatasetType.Valid,n_batch=500)) and didn’t notice differences. What value would be good? There are 200 entries in prediction.