Skip to content
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

C++ TorchScript example #13

Open
wants to merge 3 commits into
base: torch
Choose a base branch
from
Open

C++ TorchScript example #13

wants to merge 3 commits into from

Conversation

Mika412
Copy link

@Mika412 Mika412 commented Jul 10, 2023

So I've added a C++ TorchScript example. Unfortunately, I wasn't able to get it running with CUDA, only the CPU.

Steps to run:

  1. wget https://download.pytorch.org/libtorch/nightly/cpu/libtorch-shared-with-deps-latest.zip
  2. unzip libtorch-shared-with-deps-latest.zip
  3. cd cpp_test
  4. mkdir build && cd build
  5. cmake -DCMAKE_PREFIX_PATH=/path/to/libtorch ..
  6. cmake --build . --config Release
  7. ./test_app ../../scripts/scripted_controller.pt

@NicolayP
Copy link
Owner

Will have a look at it. Do you have time metrics associated with it? :)

@Mika412
Copy link
Author

Mika412 commented Jul 10, 2023

Was just getting them.

C++ CPU:
image

Python GPU:
image

@NicolayP
Copy link
Owner

So we have a small improvement over onnx, this is still with k=20/h=5 right?

@Mika412
Copy link
Author

Mika412 commented Jul 10, 2023

The results are for k=100/h=10

@NicolayP
Copy link
Owner

After 3h27min i get this error. Seems very blurry to me, any clue?
Screenshot from 2023-07-10 16-06-38

@Mika412
Copy link
Author

Mika412 commented Jul 10, 2023

Ohh, damn 3h.... I don't think it's anything with the code per se. Most likely it's due to the Pytorch version. I'm using the latest nightly, 2.1.0.dev20230709+cu121.
But did it work with smaller params?

@NicolayP
Copy link
Owner

Okay will try to upgrade pytorch, I haven't tried compiling with smaller parameters, going to do that now :)

@NicolayP
Copy link
Owner

Hey can you update the requirments.txt file that you use? The current one points to torch 1.2.1. Would like to try with the same environment setup as yours

@Mika412
Copy link
Author

Mika412 commented Jul 11, 2023

Sorry about the delay. Too many meetings... I've updated the requirements.txt, but it may have some extra unnecessary dependencies, as I'm using this env for both projects.

@NicolayP
Copy link
Owner

And out of curiosity what version of pyhon and what version of linux are you running? I can't seem to find pytorch 2.1.x_dev. And I'm not sure if I just need to update python to a newer version or install pytorch from source

@Mika412
Copy link
Author

Mika412 commented Jul 12, 2023

I'm on Ubuntu 22.04, using Python 3.9.17 in a conda environment. You can just install the latest nightly pytorch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants