caffe , When does Caffe make copies of the data?
When does Caffe make copies of the data?
// Assuming that data are on the CPU initially, and we have a blob.
const Dtype* foo;
foo = blob.gpu_data(); // data copied cpu->gpu.
foo = blob.cpu_data(); // no data copied since both have up-to-date contents.
bar = blob.mutable_gpu_data(); // no data copied.
// ... some operations ...
bar = blob.mutable_gpu_data(); // no data copied when we are still on GPU.
foo = blob.cpu_data(); // data copied gpu->cpu, since the gpu side has modified the data
foo = blob.gpu_data(); // no data copied since both have up-to-date contents
bar = blob.mutable_cpu_data(); // still no data copied.
bar = blob.mutable_gpu_data(); // data copied cpu->gpu.
bar = blob.mutable_cpu_data(); // data copied gpu->cpu
Why do the last two lines copy data? Don't the GPU and CPU have both up-to-date contents?
.cpu_data are used in cases were the
data is used only as input and will not be modified by the algorithm.
.mutable_* is used when the data itself gets updated while running the algorithm.
Whenever a the data is called, it checks whether the previous statement was a
mutable_* function call and that too using the same processor (gpu or cpu). If it is using the same processor, data need not be copied. If it is using the other processor, there is a chance that the data might have been updated in the previous
.mutable_* call and hence a data copy is required.
Edit 1 Whenever the previous instruction is 'mutable', data copy is to be done before the current instruction IF the current instruction is on a different processor.
In no other case the data copy takes place except for a special initial condition, ie; when no data was present at all in the GPU memory and hence a copy of the data will take place before *_gpu_data() call.
I have this error and I have tried to take a look in Internet but I got nothing clear. I trained my net with Caffe successfully with around 82% of accuracy. Now I'm trying to try it with an image through this code: python python/classify.py --model_def examples/imagenet/imagenet_deploy.prototxt --pretrained_model caffe_mycaffe_train_iter_10000.caffemodel --images_dim...
// Assuming that data are on the CPU initially, and we have a blob. const Dtype* foo; Dtype* bar; foo = blob.gpu_data(); // data copied cpu->gpu. foo = blob.cpu_data(); // no data copied since both have up-to-date contents. bar = blob.mutable_gpu_data(); // no data copied. // ... some operations...
I am using caffe in python to classify. I get code from here. In here, I just use simple code such as plt.rcParams['figure.figsize'] = (10, 10) plt.rcParams['image.interpolation'] = 'nearest' plt.rcParams['image.cmap'] = 'gray' mean_filename='./mean.binaryproto' proto_data = open(mean_filename, "rb").read() a = caffe.io.caffe_pb2.BlobProto.FromString(proto_data) mean = caffe.io.blobproto_to_array(a) age_net_pretrained='./age_net.caffemodel' age_net_model_file='./deploy_age.prototxt' age_net = caffe.Classifier(age_net_model_file,...
So I just pulled the latest revision of Caffe from the master branch, and went through all the initialization steps. As a quick test, I was trying to run the python/draw_net.py script provided, in order to visualize the MNIST Autoencoder example network. On executing the following command: ./python/draw_net.py examples/mnist/mnist_autoencoder.prototxt trial_viz.png...
I'm installing Caffe on an Ubuntu 14.04 virtual server with CUDA installed (without driver) using https://github.com/BVLC/caffe/wiki/Ubuntu-14.04-VirtualBox-VM as inspiration. During the installation process I edited the MakeFile to include "CPU_ONLY := 1" before building it. However, it seems that Caffe is still trying to make use of the GPU. When I...
I successfully trained my Caffe net on the mnist database following http://caffe.berkeleyvision.org/gathered/examples/mnist.html Now I want to test the network with my own images using the Matlab wrapper. Therefore in "matcaffe.m" im loading the file "lenet.prototxt" which is not used for training but which seems to be suited for testing. It...
I've installed Caffe on my Ubuntu 14.04 machine. the make runtest runs perfectly fine with 581 tests passed. I'm trying to work with the command line and python interface and getting the following two errors: Command Line Interface: When I try to run the command caffe, I'm getting the following...
I'm trying to create an LMDB data base file in Python to be used with Caffe according to this tutorial. The commands import numpy as np and import caffe run perfectly fine. However, when I try to run import lmdb and import deepdish as dd, I'm getting the following errors:...
I'm using the pretrained imagenet model provided along the caffe (CNN) library ('bvlc_reference_caffenet.caffemodel'). I can output a 1000 dim vector of object scores for any images using this model. However I don't know what the actual object categories are. Did someone find a file, where the corresponding object categories are...
i compiled caffe successfully in my ubuntu machine but cannot import in python. Caffe is installed /home/pbu/Desktop/caffe i tried adding the /home/pbu/caffe/python path to sys.path.append, still not working i am trying to import caffe [email protected]:/home/pbu/Desktop# python ./caffe/output.py Traceback (most recent call last): File "./caffe/output.py", line 13, in <module> import caffe...
I am trying to build my C++ application that uses caffe, in Debug Mode, VS2013 community, x64. To be able to build version that do not need cuda to run, I added to wrapped each .cu file as indicated below: #ifndef CPU_ONLY // .cu file contents #endif The project was...
I need pseudo inverse and transpose function to implement a Layer in caffe. So I am using Armadillo library to do that. But How can I convert Caffe Blobs(2-D) to armadillo Mat and vice-versa ?
I cannot import caffe into (anaconda-) python. I'm following a notebook example on "logistic regression on non-image HDF5 data". When I execute the line import caffe I get the following error: --------------------------------------------------------------------------- ImportError Traceback (most recent call last) <ipython-input-17-3524921938b5> in <module>() 8 sys.path.insert(0, caffe_root + 'python') 9 ---> 10 import...
I've installed caffe on a server a while ago, and back then it worked properly. Now I'm following the LeNet MNIST tutorial again (http://caffe.berkeleyvision.org/gathered/examples/mnist.html), and running ./examples/mnist/create_mnist.sh returns build/examples/mnist/convert_mnist_data.bin: error while loading shared libraries: libglog.so.0: cannot open shared object file: No such file or directory I've noticed that liibglog.so.0 is...
I'm trying to create an LMDB database file to be used with Caffe according to this tutorial on an Ubuntu 14.04 machine using Anaconda Python 2.7.9. However, when I do pip install deepdish, I'm getting the following error: Collecting deepdish Using cached deepdish-0.1.4.tar.gz Complete output from command python setup.py egg_info:...
I have been able to install Caffe but I had a lot of issues and that's because I didn't follow the instructions very well. I have a Mac OSx and I'm reading the OSx guide for installation. In this point: when I type hdf5 opencv I get: "hdf5: command not...
Recently, I've been trying to use Caffe for some of the deep learning work that I'm doing. Although writing the model in Caffe is very easy, I've not been able to know the answer to this question. How does Caffe determine the number of neurons in a hidden layer? I...
I'm trying to load in TEST phase a network configuration which has a memory data layer first and then a convolution layer. The MemoryData layer creation succeeds, But the convolution layer's creation fails at the following location: LOG(INFO) << "Creating layer " << param.name(); const string& type = param.type(); CreatorRegistry&...
I have operated CNN using caffe. however, system was forced termination. I have caffemodel so far. Can I restart learning from now on using current caffemodel? Thanks,...
I'm trying to run Caffe in it's Python interface. I've already run the command make pycaffe in the caffe directory and it worked fine. Now, when I run the command import caffe in the python environment in the terminal (Ubuntu 14.04), I'm getting the following error: >>> import caffe Traceback...
In python when I want to get the data from a layer using caffe I have the following code input_image = caffe.io.load_image(imgName) input_oversampled = caffe.io.resize_image(input_image, self.net.crop_dims) prediction = self.net.predict([input_image]) caffe_input = np.asarray(self.net.preprocess('data', prediction)) self.net.forward(data=caffe_input) data = self.net.blobs['fc7'].data // I want to get this value in lua Hoever when I'm using...
I'd like to train a neural network (NN) on my own 1-dim data, which I stored in a hdf5 database for caffe. According to the documetation this should work. It also works for me as far as I only use "Fully Connected Layers", "Relu" and "Dropout". However I get an...