-
Notifications
You must be signed in to change notification settings - Fork 9.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compile errors in cpp code #1180
Comments
Wanna send out a PR? We also dont have any good tests for the C++ code so would love to merge something here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Context
Your Environment
Current Behavior
build custom-dataset, get 3 error
build distributed, get 2 error
Possible Solution
project custom-dataset:
error 1 and 2 because std::random_shuffle no longer exists in C++17, so I fixed std::random_shuffle with std::shuffle
e.g.
change
std::random_shuffle(train.begin(), train.end());
std::random_shuffle(test.begin(), test.end());
to
std::random_device rd;
std::mt19937 seed_train(rd());
std::mt19937 seed_test(rd());
std::shuffle(train.begin(), train.end(), seed_train);
std::shuffle(test.begin(), test.end(), seed_test);
I can't fix the 3rd error.
project distributed:
change
#include <c10d/ProcessGroupMPI.hpp>
to
#include <torch/csrc/distributed/c10d/ProcessGroupMPI.hpp>
at line 52
auto pg = c10d::ProcessGroupMPI::createProcessGroupMPI();
return type is c10::intrusive_ptr
and in function waitWork, the type is
void waitWork(std::shared_ptrc10d::ProcessGroupMPI pg, std::vector<std::shared_ptrc10d::ProcessGroupMPI::WorkMPI> works)
so I changed waitWork to
void waitWork(c10::intrusive_ptrc10d::ProcessGroupMPI pg, std::vector<c10::intrusive_ptrc10d::ProcessGroupMPI::WorkMPI> works)
and get 2 error
/opt/libtorch/include/c10/util/intrusive_ptr.h:348:13: error: no matching function for call to 'assign_ptr_'
I can't fix the error.
Steps to Reproduce
cd custom-dataset
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH=/opt/libtorch ..
make
...
cd distributed
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH=/opt/libtorch ..
make
Failure Logs [if any]
/Users/anthony/Rnd/gits/pytorch/examples/cpp/custom-dataset/custom-dataset.cpp:90:8: error: no member named 'random_shuffle' in namespace 'std'
std::random_shuffle(train.begin(), train.end());
/Users/anthony/Rnd/gits/pytorch/examples/cpp/custom-dataset/custom-dataset.cpp:91:8: error: no member named 'random_shuffle' in namespace 'std'
std::random_shuffle(test.begin(), test.end());
/Users/anthony/Rnd/gits/pytorch/examples/cpp/custom-dataset/custom-dataset.cpp:122:15: error: no matching constructor for initialization of 'torch::nn::Functional'
push_back(Functional(torch::log_softmax, 1, torch::nullopt));
The text was updated successfully, but these errors were encountered: