From d513ef6b5950616dea945095d73e7bde76754de1 Mon Sep 17 00:00:00 2001 From: Daniel Suo Date: Wed, 18 Nov 2015 02:50:59 -0500 Subject: [PATCH 1/2] Get initial version of Marvin working on Windows Very hacky; just doing the minimal things to compile and run MNIST - Replace sys/time.h with chrono - Remove async calls - Remove threading --- marvin.hpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/marvin.hpp b/marvin.hpp index 162ab30..6e4949d 100644 --- a/marvin.hpp +++ b/marvin.hpp @@ -80,7 +80,7 @@ #include #include #include -#include +#include namespace marvin { @@ -168,9 +168,7 @@ void checkCUBLAS(const int lineNumber, cublasStatus_t status) { } unsigned long long get_timestamp() { - struct timeval now; - gettimeofday (&now, NULL); - return now.tv_usec + (unsigned long long)now.tv_sec * 1000000; + return (unsigned long long)std::chrono::duration_cast(std::chrono::high_resolution_clock::now().time_since_epoch()).count(); } unsigned long long ticBegin; @@ -2850,7 +2848,7 @@ class MemoryDataLayer : public DataLayer { template class DiskDataLayer : public DataLayer { - std::future lock; + //std::future lock; FILE* dataFILE; Tensor* labelCPUall; std::vector ordering; @@ -2964,7 +2962,7 @@ class DiskDataLayer : public DataLayer { }; ~DiskDataLayer(){ - if (lock.valid()) lock.wait(); + // if (lock.valid()) lock.wait(); delete distribution_bernoulli; for (int i=0;i>>(CUDA_GET_LOOPS(numel_batch_all_channel_crop), numel_batch_all_channel_crop, numel_all_channel_crop, dataGPU, (in.size()==0? NULL: in[0]->dataGPU), out[0]->dataGPU); std::swap(out[1]->dataGPU,labelGPU); - lock = std::async(std::launch::async,&DiskDataLayer::prefetch,this); + // lock = std::async(std::launch::async,&DiskDataLayer::prefetch,this); + prefetch(); }; @@ -3111,8 +3110,8 @@ class DiskDataLayer : public DataLayer { checkCUDA(__LINE__, cudaMalloc(&dataGPU, numel_batch_all_channel_crop * sizeof(T)) ); memoryBytes += numel_batch_all_channel_crop * sizeof(T); - lock = std::async(std::launch::async,&DiskDataLayer::prefetch,this); - + // lock = std::async(std::launch::async,&DiskDataLayer::prefetch,this); + prefetch(); return memoryBytes; }; }; @@ -3547,7 +3546,7 @@ class InnerProductLayer : public Layer { class DropoutLayer: public Layer{ ComputeT scale; std::bernoulli_distribution* distribution; - std::future lock; + // std::future lock; bool current_mask; std::vector< StorageT* > GPUmask[2]; std::vector< StorageT* > CPUmask; @@ -3619,13 +3618,13 @@ class DropoutLayer: public Layer{ memoryBytes += out[i]->Malloc(in[i]->dim); } - lock = std::async(std::launch::async,&DropoutLayer::generateMask,this); - + // lock = std::async(std::launch::async,&DropoutLayer::generateMask,this); + generateMask(); return memoryBytes; }; ~DropoutLayer(){ - if (lock.valid()) lock.wait(); + // if (lock.valid()) lock.wait(); for (int i=0;idataGPU, GPUmask[current_mask][i], in[i]->dataGPU); @@ -5565,7 +5565,7 @@ class Solver{ }else{ for (int t=0; tphase = Testing; - threads[t] = std::thread(&Net::stepTest, nets[t], true); //nets[t]->stepTest(); + // threads[t] = std::thread(&Net::stepTest, nets[t], true); //nets[t]->stepTest(); } for (int t=0; tstepTrain(false); }else{ for (int t=0; tstepTrain(); + // threads[t] = std::thread(&Net::stepTrain, nets[t], true); //nets[t]->stepTrain(); } for (int t=0; teval(false); }else{ for (int t=0; teval(); + // threads[t] = std::thread(&Net::eval, nets[t], true); //nets[t]->eval(); } for (int t=0; t Date: Wed, 18 Nov 2015 03:08:22 -0500 Subject: [PATCH 2/2] Update README with Windows instructions and instructions for using prebuilt data --- README.md | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8f0120b..4ae9570 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,11 @@ Marvin is a GPU-only neural network framework made with simplicity, hackability, speed, memory consumption, and high dimensional data in mind. -## Dependences +## Dependencies -Download [CUDA 7.5](https://developer.nvidia.com/cuda-downloads) and [cuDNN 3](https://developer.nvidia.com/cudnn). You will need to register with NVIDIA. Below are some additional steps to set up cuDNN 3: +Download [CUDA 7.5](https://developer.nvidia.com/cuda-downloads) and [cuDNN 3](https://developer.nvidia.com/cudnn). You will need to register with NVIDIA. For Windows, you will need to download Microsoft Visual Studio 2013 [here](http://go.microsoft.com/fwlink/?LinkId=517284). Below are some additional steps to set up cuDNN 3: +### Linux and OS X ```shell CUDA_LIB_DIR=/usr/local/cuda/lib$([[ $(uname) == "Linux" ]] && echo 64) echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CUDA_LIB_DIR >> ~/.profile && ~/.profile @@ -15,17 +16,46 @@ sudo cp cuda/lib/* $CUDA_LIB_DIR sudo cp cuda/include/* /usr/local/cuda/include ``` +### Windows +- Copy ```CUDNN_PATH/bin/*``` to ```CUDA_PATH/bin``` +- Copy ```CUDNN_PATH/lib/*``` to ```CUDA_PATH/lib``` +- Copy ```CUDNN_PATH/include/*``` to ```CUDA_PATH/include``` + ## Compilation +### Linux and OS X ```shell ./compile.sh ``` +### Windows +- Create a new project in Visual Studio 2013 + - File -> New Project (Ctrl-Shift-N) + - Installed -> Templates -> NVIDIA -> CUDA 7.5 +- Add ```marvin.hpp``` and ```marvin.cu``` to the project + - Project -> Add Existing Item (Shift-Alt-A) + - Select ```marvin.hpp``` and ```marvin.cu``` from Explorer +- Add cuDNN and cuBLAS libraries + - Project -> [Project Name] Properties -> Configuration Properties -> Linker -> Input + - Add ```cudnn.lib``` and ```cublas.lib``` to the semicolon-delimited list called ```Additional Dependencies``` (assumes both files are in ```CUDA_PATH/lib```) +- Build project and run ```marvin.exe``` with appropriate commands + ## MNIST -1. Prepare data: run examples/mnist/prepare_mnist.m in Matlab -2. Train a model: run ./examples/mnist/demo.sh in shell -3. Visualize filters: run examples/mnist/demo_vis_filter.m in Matlab +### Creating from scratch +1. Prepare data: run ```examples/mnist/prepare_mnist.m``` in ```MATLAB``` +2. Train a model: run ```examples/mnist/demo.sh in``` ```shell``` +3. Visualize filters: run ```examples/mnist/demo_vis_filter.m``` in ```MATLAB``` + +### Using prebuilt data +1. Download four tensor files to ```examples/mnist``` + - [Test images](http://vision.princeton.edu/marvin/mnist/test-images.tensor) + - [Test labels](http://vision.princeton.edu/marvin/mnist/test-labels.tensor) + - [Training images](http://vision.princeton.edu/marvin/mnist/train-images.tensor) + - [Training labels](http://vision.princeton.edu/marvin/mnist/train-labels.tensor) +2. Run Marvin from the root directory + - Train: ```marvin train examples/mnist/lenet.json``` + - Test: ```marvin test examples/mnist/lenet.json examples/mnist/lenet.marvin``` ## Tutorials and Documentation Please see our website at [http://marvin.is](http://marvin.is).