2/03/2016

First Microsoft CNTK Project in Visual Studio on Windows (Part 2)

Microsoft open sourced and released their version of deep learning to GitHub last week.  I downloaded the source code, did the required installs and tried to get the examples to work.  After hours and hours, I had to step away.

Except that when I work on a problem, it's difficult to let it sit, unsolved.

So today, I downloaded the latest build of the project:

https://github.com/Microsoft/CNTK/releases

Install Instructions:

https://github.com/Microsoft/CNTK/wiki/CNTK-Binary-Download-and-Configuration

Going to try again.

Luckily, all the core installs are already on this laptop.


Apparently, my laptop has insufficient memory to handle the Python script.  No way around it.  Except to reduce the size of the array, by reducing the number of files to parse through.

Opening the Python file in IDLE, Python's Integrated Development Environment, it appears to be crapping out during the "Preparing train set...

So I changed the Range from 5 to 2, and it seems to run okay without errors:




 Done.





 It created a few files, Test.txt and Train.txt



So after re-compiling the new version of the Visual Studio project, adding the command line argument to the CNTK:

configFile=C:\Users\jbloom\Desktop\BloomConsulting\MicrosoftCNTK\CNTK-r2016-01-26\Examples\Image\Miscellaneous\CIFAR-10\01_Conv.config configName=01_Conv OutputDir=C:\Users\jbloom\Desktop\BloomConsulting\MicrosoftCNTK\CNTK-r2016-01-26\Examples\Image\Miscellaneous\CIFAR-10\Output


Ran the project, no errors this time:



Reviewing the Log file, it threw an error, couldn't file a file:

<<<<<<<<<<<<<<<<<<<< PROCESSED CONFIG WITH ALL VARIABLES RESOLVED <<<<<<<<<<<<<<<<<<<<
command: Train Test
precision = float
CNTKModelPath: C:\Users\jbloom\Desktop\BloomConsulting\MicrosoftCNTK\CNTK-r2016-01-26\Examples\Image\Miscellaneous\CIFAR-10\Output/Models/01_Convolution
CNTKCommandTrainInfo: Train : 30
CNTKCommandTrainInfo: CNTKNoMoreCommands_Total : 30
CNTKCommandTrainBegin: Train
About to throw exception 'error opening file './Macros.ndl': No such file or directory'

[CALL STACK]
    >Microsoft::MSR::CNTK::ThrowFormatted
    -Microsoft::MSR::CNTK::RuntimeError
    -fopenOrDie
    -::operator()
    -Microsoft::MSR::CNTK::attempt< >
    -Microsoft::MSR::CNTK::attempt< >
    -Microsoft::MSR::CNTK::File::Init
    -Microsoft::MSR::CNTK::File::File
    -Microsoft::MSR::CNTK::ConfigParser::ReadConfigFile
    -Microsoft::MSR::CNTK::ConfigParser::LoadConfigFileAndResolveVariables
    -Microsoft::MSR::CNTK::NDLBuilder::Init
    -Microsoft::MSR::CNTK::NDLBuilder::NDLBuilder
    -std::_Ref_count_obj >::_Ref_count_obj >


However, the file does exist.  So let's explicitly declare the ConfigDir:

configFile=C:\Users\jbloom\Desktop\BloomConsulting\MicrosoftCNTK\CNTK-r2016-01-

26\Examples\Image\Miscellaneous\CIFAR-10\01_Conv.config configName=01_Conv OutputDir=C:\Users\jbloom\Desktop\BloomConsulting\MicrosoftCNTK\CNTK-r2016-01-26\Examples\Image\Miscellaneous\CIFAR-10\Output ConfigDir=C:\Users\jbloom\Desktop\BloomConsulting\MicrosoftCNTK\CNTK-r2016-01-26\Examples\Image\Miscellaneous\CIFAR-10

Error:

<<<<<<<<<<<<<<<<<<<< PROCESSED CONFIG WITH ALL VARIABLES RESOLVED <<<<<<<<<<<<<<<<<<<<
command: Train Test
precision = float
CNTKModelPath: C:\Users\jbloom\Desktop\BloomConsulting\MicrosoftCNTK\CNTK-r2016-01-26\Examples\Image\Miscellaneous\CIFAR-10\Output/Models/01_Convolution
CNTKCommandTrainInfo: Train : 30
CNTKCommandTrainInfo: CNTKNoMoreCommands_Total : 30
CNTKCommandTrainBegin: Train
NDLBuilder Using CPU
Reading UCI file ./Train.txt
About to throw exception 'UCIParser::ParseInit - error opening file'

Need to specify the DataDir:

configFile=C:\Users\jbloom\Desktop\BloomConsulting\MicrosoftCNTK\CNTK-r2016-01-

26\Examples\Image\Miscellaneous\CIFAR-10\01_Conv.config configName=01_Conv OutputDir=C:\Users

\jbloom\Desktop\BloomConsulting\MicrosoftCNTK\CNTK-r2016-01-26\Examples\Image\Miscellaneous

\CIFAR-10\Output ConfigDir=C:\Users\jbloom\Desktop\BloomConsulting\MicrosoftCNTK\CNTK-r2016-01-26\Examples\Image\Miscellaneous\CIFAR-10 CNTKModelPath=C:\Users\jbloom\Desktop\BloomConsulting\MicrosoftCNTK\CNTK-r2016-01-26\Examples\Image\Miscellaneous\CIFAR-10 DataDir=C:\Users\jbloom\Desktop\BloomConsulting\MicrosoftCNTK\CNTK-r2016-01-26\Examples\Image\Miscellaneous\CIFAR-10

Looks like it ran, new error:

Validating --> OutputNodes.W = LearnableParameter -> [10 x 64 {1,10}]
Validating --> h1.W = LearnableParameter -> [64 x 576 {1,64}]
Validating --> conv3_act.W = LearnableParameter -> [64 x 800 {1,64}]
Validating --> conv2_act.W = LearnableParameter -> [32 x 800 {1,32}]
Validating --> conv1_act.W = LearnableParameter -> [32 x 75 {1,32}]
Validating --> features = InputValue -> [32 x 32 x 3 {1,32,1024} x *]
Validating --> featOffs = LearnableParameter -> [1 x 1 {1,1}]
Validating --> featScaled = Minus(features[32 x 32 x 3 {1,32,1024} x * {W=32, H=3, C=32}], featOffs[1 x 1 {1,1}]) -> [32 x 32 x 3 {1,32,1024} x *]
Validating --> conv1_act.c = Convolution(conv1_act.W[32 x 75 {1,32}], featScaled[32 x 32 x 3 {1,32,1024} x * {W=32, H=3, C=32}]) -> [32 x 32 x 32 {1,32,1024} x *]
Validating --> conv1_act.b = LearnableParameter -> [1 x 1 x 32 x 1 {1,1,1,32}]
Validating --> conv1_act.p = Plus(conv1_act.c[32 x 32 x 32 {1,32,1024} x * {W=32, H=32, C=32}], conv1_act.b[1 x 1 x 32 x 1 {1,1,1,32}]) -> [32 x 32 x 32 x 1 {1,32,1024,32768} x *]
Validating --> conv1_act.y = RectifiedLinear(conv1_act.p[32 x 32 x 32 x 1 {1,32,1024,32768} x *]) -> [32 x 32 x 32 x 1 {1,32,1024,32768} x *]
Validating --> pool1 = MaxPooling(conv1_act.y[32 x 32 x 32 x 1 {1,32,1024,32768} x *])About to throw exception 'Convolution operation currently only supports 1D or 2D convolution on 3D tensors.'

At this point, I reran the Python script, to convert the images to Legacy, hard coded the fmt value in the script and re-ran:


if __name__ == "__main__":
    fmt = 'legacy'
    trn, tst = loadData('http://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz', fmt)
    print 'Writing train text file...'
    np.savetxt(r'./Train.txt', trn, fmt = '%u', delimiter='\t')
    print 'Done.'
    print 'Writing test text file...'
    np.savetxt(r'./Test.txt', tst, fmt = '%u', delimiter='\t')


I read something about the possibility, the path can not exceed a certain length, so moved the entire project folder to the C:\ Drive.

Modified the input parameters:


configFile=C:\cntk\MicrosoftCNTK\CNTK-r2016-01-26\Examples\Image\Miscellaneous\CIFAR-10\01_Conv.config configName=01_Conv OutputDir=C:\cntk\MicrosoftCNTK\CNTK-r2016-01-26\Examples\Image\Miscellaneous\CIFAR-10\Output ConfigDir=C:\cntk\MicrosoftCNTK\CNTK-r2016-01-26\Examples\Image\Miscellaneous\CIFAR-10  CNTKModelPath=C:\cntk\MicrosoftCNTK\CNTK-r2016-01-26\Examples\Image\Miscellaneous\CIFAR-10 DataDir=C:\cntk\MicrosoftCNTK\CNTK-r2016-01-26\Examples\Image\Miscellaneous\CIFAR-10  ModelDir=C:\cntk\MicrosoftCNTK\CNTK-r2016-01-26\Examples\Image\Miscellaneous\CIFAR-10 deviceId=0

Error:

<<<<<<<<<<<<<<<<<<<< PROCESSED CONFIG WITH ALL VARIABLES RESOLVED <<<<<<<<<<<<<<<<<<<<
command: Train Test
precision = float
CNTKModelPath: C:\cntk\MicrosoftCNTK\CNTK-r2016-01-26\Examples\Image\Miscellaneous\CIFAR-10/01_Convolution
CNTKCommandTrainInfo: Train : 30
CNTKCommandTrainInfo: CNTKNoMoreCommands_Total : 30
CNTKCommandTrainBegin: Train
NDLBuilder Using GPU 0
Reading UCI file C:\cntk\MicrosoftCNTK\CNTK-r2016-01-26\Examples\Image\Miscellaneous\CIFAR-10/Train.txt
About to throw exception 'CUDA failure 35: CUDA driver version is insufficient for CUDA runtime version ; GPU=-1 ; hostname=BLOOMLAPTOP ; expr=cudaSetDevice(deviceId)'



This is a documented error found here on the GitHub website for the project:

https://github.com/Microsoft/CNTK/issues/55

To summarize, I got passed the error of insufficient memory, by limiting the loop to parse files up to 2, instead of 5, so the data set was smaller.  However, I couldn't get passed the bug which is documented on the website.  And there you have it.  Thanks for reading~!

Original Post on CNTK: http://www.bloomconsultingbi.com/2016/01/first-microsoft-cntk-project-in-visual.html

First Project on CNTK in Visual Studio: http://www.bloomconsultingbi.com/2016/01/first-microsoft-cntk-project-in-visual.html