Unable to read Data using PyTorch C++ API (MNIST)

Yes, the source files are not included in the distributions. So that’s normal. Just download / clone the repo and point that for VS.

Thanks!

I included the repo in directory by going to the project properties, but here are the errors I get. Any idea why?

Error (active)	E0135	namespace "at" has no member "WeakIValue"	example	C:\Users\krshr\OneDrive\Documents\pytorch\torch\csrc\jit\tracer.h	68	
Error	C2039	 'WeakIValue': is not a member of 'at'	example	C:\Users\krshr\OneDrive\Documents\pytorch\torch\csrc\jit\tracer.h	68	
Error	C2061	 syntax error: identifier 'WeakIValue'	example	C:\Users\krshr\OneDrive\Documents\pytorch\torch\csrc\jit\tracer.h	68	
Error	C4430	 missing type specifier - int assumed. Note: C++ does not support default-int	example	C:\Users\krshr\OneDrive\Documents\pytorch\torch\csrc\jit\tracer.h	71	
Error	C2143	 syntax error: missing ',' before '&'	example	C:\Users\krshr\OneDrive\Documents\pytorch\torch\csrc\jit\tracer.h	71	
Error	C4430	 missing type specifier - int assumed. Note: C++ does not support default-int	example	C:\Users\krshr\OneDrive\Documents\pytorch\torch\csrc\jit\tracer.h	77	
Error	C2143	 syntax error: missing ',' before '&'	example	C:\Users\krshr\OneDrive\Documents\pytorch\torch\csrc\jit\tracer.h	77	
Error	C2065	 'WeakIValue': undeclared identifier	example	C:\Users\krshr\OneDrive\Documents\pytorch\torch\csrc\jit\tracer.h	82	
Error	C2923	 'std::unordered_map': 'WeakIValue' is not a valid template type argument for parameter '_Kty'	example	C:\Users\krshr\OneDrive\Documents\pytorch\torch\csrc\jit\tracer.h	82	
Error	C3203	 'pair': unspecialized class template can't be used as a template argument for template parameter '_Ty', expected a real type	example	C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include\unordered_map	75	
Error	C2923	 'std::unordered_map': 'WeakIValue' is not a valid template type argument for parameter '_Kty'	example	C:\Users\krshr\OneDrive\Documents\pytorch\torch\csrc\jit\tracer.h	82	
Error	C3203	 'unordered_map': unspecialized class template can't be used as a template argument for template parameter '_Ty', expected a real type	example	C:\Users\krshr\OneDrive\Documents\pytorch\torch\csrc\jit\tracer.h	83	
Error	C2065	 't': undeclared identifier	example	C:\Users\krshr\OneDrive\Documents\pytorch\torch\csrc\jit\tracer.h	72	
Error	C2065	 't1': undeclared identifier	example	C:\Users\krshr\OneDrive\Documents\pytorch\torch\csrc\jit\tracer.h	78	
Error	C2065	 't2': undeclared identifier	example	C:\Users\krshr\OneDrive\Documents\pytorch\torch\csrc\jit\tracer.h	78	
Error	C2660	 'c10::ClassType::create': function does not take 3 arguments	example	C:\Users\krshr\OneDrive\Documents\pytorch\torch\csrc\jit\script\module.h	117	
Error	C2440	 'return': cannot convert from 'torch::jit::script::CompilationUnit' to 'std::shared_ptr<torch::jit::script::CompilationUnit>'	example	C:\Users\krshr\OneDrive\Documents\pytorch\torch\csrc\jit\script\module.h	407	
Error	C2440	 'return': cannot convert from 'torch::jit::script::CompilationUnit' to 'std::shared_ptr<const torch::jit::script::CompilationUnit>'	example	C:\Users\krshr\OneDrive\Documents\pytorch\torch\csrc\jit\script\module.h	410	
Error	C2953	 'torch::OrderedDict': class template has already been defined	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	178	
Error	C2427	 'torch::OrderedDict<Key,Value>::Item': cannot define class in this scope	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	183	
Error	C2244	 'torch::OrderedDict::OrderedDict': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	238	
Error	C2244	 'torch::OrderedDict::OrderedDict': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	242	
Error	C2244	 'torch::OrderedDict::operator =': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	252	
Error	C2244	 'torch::OrderedDict::OrderedDict': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	265	
Error	C2244	 'torch::OrderedDict::begin': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	275	
Error	C2244	 'torch::OrderedDict::begin': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	281	
Error	C2244	 'torch::OrderedDict::end': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	286	
Error	C2244	 'torch::OrderedDict::end': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	292	
Error	C2244	 'torch::OrderedDict::front': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	297	
Error	C2244	 'torch::OrderedDict::front': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	304	
Error	C2244	 'torch::OrderedDict::back': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	310	
Error	C2244	 'torch::OrderedDict::back': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	317	
Error	C2244	 'torch::OrderedDict::operator []': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	324	
Error	C2244	 'torch::OrderedDict::operator []': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	331	
Error	C2244	 'torch::OrderedDict::operator []': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	337	
Error	C2244	 'torch::OrderedDict::operator []': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	345	
Error	C2244	 'torch::OrderedDict::insert': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	354	
Error	C2244	 'torch::OrderedDict::insert': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	364	
Error	C2244	 'torch::OrderedDict::update': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	369	
Error	C2244	 'torch::OrderedDict::update': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	378	
Error	C2244	 'torch::OrderedDict::find': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	387	
Error	C2244	 'torch::OrderedDict::find': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	396	
Error	C2244	 'torch::OrderedDict::contains': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	405	
Error	C2244	 'torch::OrderedDict::clear': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	410	
Error	C2244	 'torch::OrderedDict::size': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	416	
Error	C2244	 'torch::OrderedDict::is_empty': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	421	
Error	C2244	 'torch::OrderedDict::key_description': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	426	
Error	C2244	 'torch::OrderedDict::items': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	433	
Error	C2244	 'torch::OrderedDict::keys': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	438	
Error	C2244	 'torch::OrderedDict::values': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	448	
Error	C2244	 'torch::OrderedDict::pairs': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	458	
Error	C2244	 'torch::OrderedDict::reserve': unable to match function definition to an existing declaration	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\ordered_dict.h	468	
Error	C2662	 'size_t torch::OrderedDict<Key,Value>::size(void) noexcept const': cannot convert 'this' pointer from 'torch::OrderedDict' to 'const torch::OrderedDict<Key,Value> &'	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\nn\modules\sequential.h	109	
Error	C2663	 'torch::OrderedDict<Key,Value>::begin': 2 overloads have no legal conversion for 'this' pointer	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\nn\modules\sequential.h	110	
Error	C2663	 'torch::OrderedDict<Key,Value>::end': 2 overloads have no legal conversion for 'this' pointer	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\nn\modules\sequential.h	110	
Error	C3536	 '<begin>$L0': cannot be used before it is initialized	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\nn\modules\sequential.h	110	
Error	C3536	 '<end>$L0': cannot be used before it is initialized	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\nn\modules\sequential.h	110	
Error	C2100	 illegal indirection	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\nn\modules\sequential.h	110	
Error	C2672	 'std::move': no matching overloaded function found	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\nn\modules\sequential.h	111	
Error	C2780	 '_DestTy *std::move(_InIt,_InIt,_DestTy (&)[_DestSize])': expects 3 arguments - 1 provided	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\nn\modules\sequential.h	111	
Error	C2780	 '_OutIt std::move(_InIt,_InIt,_OutIt)': expects 3 arguments - 1 provided	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\nn\modules\sequential.h	111	
Error	C2672	 'std::move': no matching overloaded function found	example	C:\Users\krshr\Downloads\Compressed\libtorch\include\torch\csrc\api\include\torch\nn\modules\sequential.h	111	

This error appears when using Microsoft Visual Studio 2019 x64 instead of Ninja.

When trying Ninja, the error is same. It says it can not find c:\w\1\s\windows\pytorch\torch\csrc\api\src\data\datasets\mnist.cpp. Is there anything wrong with the initials of the path: c:\w\1\s\windows\? This path doesn’t exist, right?

Oh! Finally done. Looks like there was a problem with path to the source repo of PyTorch.

Thanks @peterjc123 for your patience! :+1:

I’m having the same problems. What were the exact steps you took to fix this.

I have both the repo and the libtorch downloaded but I’m not sure how to point one to the other.

Thanks,
dave