Hey everyone!
I was giving the new rc1 for version 1.0 a shot to checkout the C++ front end. I am using Mac OS and compiled from the master branch.
I was then trying the MNIST CNN example found here: https://github.com/goldsborough/examples/blob/cpp/cpp/mnist/mnist.cpp
However, I am running into a bit of trouble where torch::data
does not seem to be available. Here is build print statements and the error:
buid cmake -DCMAKE_PREFIX_PATH=$LIBTORCH_PATH ..
-- The C compiler identification is AppleClang 10.0.0.10001044
-- The CXX compiler identification is AppleClang 10.0.0.10001044
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE
-- Downloading MNIST dataset
Downloading http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz ...
0% |################################################################| 100%
Unzipped /Users/yngtodd/src/sandbox/pytorch/mnist/buid/data/train-images-idx3-ubyte.gz ...
Downloading http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz ...
0% |################################################################| 100%
Unzipped /Users/yngtodd/src/sandbox/pytorch/mnist/buid/data/train-labels-idx1-ubyte.gz ...
Downloading http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz ...
0% |################################################################| 100%
Unzipped /Users/yngtodd/src/sandbox/pytorch/mnist/buid/data/t10k-images-idx3-ubyte.gz ...
Downloading http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz ...
0% |################################################################| 100%
Unzipped /Users/yngtodd/src/sandbox/pytorch/mnist/buid/data/t10k-labels-idx1-ubyte.gz ...
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/yngtodd/src/sandbox/pytorch/mnist/buid
And the error:
buid make
Scanning dependencies of target mnist
[ 50%] Building CXX object CMakeFiles/mnist.dir/mnist.cpp.o
/Users/yngtodd/src/sandbox/pytorch/mnist/mnist.cpp:61:31: error: no member named 'data' in
namespace 'torch'
data_loader.loop([&](torch::data::Example<>& batch) {
~~~~~~~^
/Users/yngtodd/src/sandbox/pytorch/mnist/mnist.cpp:84:31: error: no member named 'data' in
namespace 'torch'
data_loader.loop([&](torch::data::Example<>& batch) {
~~~~~~~^
/Users/yngtodd/src/sandbox/pytorch/mnist/mnist.cpp:120:30: error: no member named 'data' in
namespace 'torch'
auto train_loader = torch::data::data_loader(
~~~~~~~^
/Users/yngtodd/src/sandbox/pytorch/mnist/mnist.cpp:121:14: error: no member named 'data' in
namespace 'torch'
torch::data::datasets::MNIST(options.data_root, /*train=*/true)
~~~~~~~^
/Users/yngtodd/src/sandbox/pytorch/mnist/mnist.cpp:122:23: error: no member named 'data' in
namespace 'torch'
.map(torch::data::transforms::Normalize<>(0.1307, 0.3081))
~~~~~~~^
/Users/yngtodd/src/sandbox/pytorch/mnist/mnist.cpp:122:51: error: expected expression
.map(torch::data::transforms::Normalize<>(0.1307, 0.3081))
^
/Users/yngtodd/src/sandbox/pytorch/mnist/mnist.cpp:122:53: warning: expression result unused
[-Wunused-value]
.map(torch::data::transforms::Normalize<>(0.1307, 0.3081))
^~~~~~
/Users/yngtodd/src/sandbox/pytorch/mnist/mnist.cpp:123:23: error: no member named 'data' in
namespace 'torch'
.map(torch::data::transforms::Stack<>()),
~~~~~~~^
/Users/yngtodd/src/sandbox/pytorch/mnist/mnist.cpp:123:47: error: expected expression
.map(torch::data::transforms::Stack<>()),
^
/Users/yngtodd/src/sandbox/pytorch/mnist/mnist.cpp:123:49: error: expected expression
.map(torch::data::transforms::Stack<>()),
^
/Users/yngtodd/src/sandbox/pytorch/mnist/mnist.cpp:124:14: error: no member named 'data' in
namespace 'torch'
torch::data::DataLoaderOptions().batch_size(options.batch_size));
~~~~~~~^
/Users/yngtodd/src/sandbox/pytorch/mnist/mnist.cpp:126:29: error: no member named 'data' in
namespace 'torch'
auto test_loader = torch::data::data_loader(
~~~~~~~^
/Users/yngtodd/src/sandbox/pytorch/mnist/mnist.cpp:127:14: error: no member named 'data' in
namespace 'torch'
torch::data::datasets::MNIST(options.data_root, /*train=*/false)
~~~~~~~^
/Users/yngtodd/src/sandbox/pytorch/mnist/mnist.cpp:128:23: error: no member named 'data' in
namespace 'torch'
.map(torch::data::transforms::Normalize<>(0.1307, 0.3081))
~~~~~~~^
/Users/yngtodd/src/sandbox/pytorch/mnist/mnist.cpp:128:51: error: expected expression
.map(torch::data::transforms::Normalize<>(0.1307, 0.3081))
^
/Users/yngtodd/src/sandbox/pytorch/mnist/mnist.cpp:128:53: warning: expression result unused
[-Wunused-value]
.map(torch::data::transforms::Normalize<>(0.1307, 0.3081))
^~~~~~
/Users/yngtodd/src/sandbox/pytorch/mnist/mnist.cpp:129:23: error: no member named 'data' in
namespace 'torch'
.map(torch::data::transforms::Stack<>()),
~~~~~~~^
/Users/yngtodd/src/sandbox/pytorch/mnist/mnist.cpp:129:47: error: expected expression
.map(torch::data::transforms::Stack<>()),
^
/Users/yngtodd/src/sandbox/pytorch/mnist/mnist.cpp:129:49: error: expected expression
.map(torch::data::transforms::Stack<>()),
^
/Users/yngtodd/src/sandbox/pytorch/mnist/mnist.cpp:130:14: error: no member named 'data' in
namespace 'torch'
torch::data::DataLoaderOptions().batch_size(options.batch_size));
~~~~~~~^
2 warnings and 18 errors generated.
make[2]: *** [CMakeFiles/mnist.dir/mnist.cpp.o] Error 1
make[1]: *** [CMakeFiles/mnist.dir/all] Error 2
make: *** [all] Error 2
Has anyone had success getting a model up and running with the C++ interface?
Thanks!