I have a quick question: when using Google Colab with the GPU enabled, does all of the code already run on the GPU then or is there some setting in the code that we must change to make it run on the GPU? Specifically, if I am training a neural network model in Keras/TF, do I need to edit my code in any way to ensure that the model is trained on the GPU?
Thanks!
as showed in the Tensorflow with Gpu example notebook you can run your model in the following way to make sure it is running on the chosen device:
def gpu():
with tf.device('/device:GPU:0'):
random_image_gpu = tf.random.normal((100, 100, 100, 3))
net_gpu = tf.keras.layers.Conv2D(32, 7)(random_image_gpu)
return tf.math.reduce_sum(net_gpu)
Related
I running DQN training tutorial with tf.agents(https://www.tensorflow.org/agents/tutorials/1_dqn_tutorial), and I am trying to change the model they use with just dense layers to have some convolutional ones on top
When I run this on colab without GPU its all fine, but when I connect to GPU I get this error.
Is it because conv layers are not available yet with GPU with tf.agents or are there some dependencies extra that I have to install to be able to do this?
Using Google Colab, I made a neural network using tensorflow that generates text based on examples. I ran 60 epochs. How can I get my neural network to maintain what it has learned. Whenever I re-run it, it starts over.
Try saving your model at the end of the training like this:
import tensorflow as tf
tf.keras.models.save_model(model, 'model/my_model')
Then you can load the model like this:
tf.keras.models.load_model('model/my_model')
I am looking the optimal way to train pre-trained models for YOLOv4
I have my local environment Debian 10 OS,
GeForce RTX 2060 SUPER
GeForce GTX 750 Ti
I planning to train the models based on different size of images, and the trained models I am going to use as part of microservices developed on java, or python.
Should I use any third party services like Google colab?
and the second question what the framework better to use ? (pytorch, tensorflow etc)
Thank you for suggestion
You can use this repo, https://github.com/AlexeyAB/darknet. It has all instructions for custom training, transfer learning and also colab training, inference script.
You can use the provided convolutional layer weights to improve results faster and on small dataset. Different dimension images can be used for training.
Custom training instructions,
https://github.com/AlexeyAB/darknet#how-to-train-to-detect-your-custom-objects
Training and inference in colab,
https://colab.research.google.com/drive/1_GdoqCJWXsChrOiY8sZMr_zbr_fH-0Fg
I have two Nvidia Titan X cards on my machine and want to finetune COCO pretrained Inception V2 model on a single specific class. I have created the train/val tfrecords and changed the config to run the tensorflow object detection training pipeline.
I am able to start the training but it hangs (without any OOM) whenever it tries to evaluate a checkpoint. Currently it is using only GPU 0 with other resource parameters (like RAM, CPU, IO etc) in normal range. So I am guessing that GPU is the bottleneck. I wanted to try splitting training and validation on separate GPUs and see if it works.
I tried to look for a place where I could do something like setting "CUDA_VISIBLE_DEVICES" differently for both the processes but unfortunately the latest tensorflow object detection API code (using tensorflow 1.12) makes it very difficult to do so. I am also unable to verify my assumption about training and validation running in same process as my machine hangs. Could someone please suggest where to look for to solve it?
I wanna use the inception v3 model in tensor flow for feature extraction. But the number of the images I am using is a lot, so it takes long time to run. So, I am going to use GPU. I have installed Cuda 7.5 and cuDnn correctly.
I am using following code in the CPU mode for one image:
with tf.Session as sess:
softmax_tensor =sess.graph.get_tensor_by_name('pool_3:0')
feat_vect = numpy.squeeze(sess.run(softmax_tensor,{'DecodeJpeg:0': in_image}))
So, my question is that how should I change my code so I can use it for many batches by GPU?