@@ -19,63 +19,72 @@ with the affected code.
1919
2020## Installation
2121
22- To work with TorchJD, we suggest you to use [ uv] ( https://docs.astral.sh/uv/ ) . While this is not
23- mandatory, we only provide installation steps with this tool. You can install it by following their
24- [ installation documentation] ( https://docs.astral.sh/uv/getting-started/installation/ ) . We also
25- suggest to use VSCode with the ` Python ` , ` ty ` and ` ruff ` extensions (without ` Pylance ` ).
22+ TorchJD provides a ** [ devcontainer] ( https://containers.dev/ ) ** configuration that gives you a
23+ ready-to-use development environment with all dependencies pre-installed. This is the recommended way
24+ to set up your environment.
2625
27- 1 ) Pre-requisites: Use ` uv ` to install a Python version compatible with TorchJD and to pin it to the
28- ` TorchJD ` folder. From the root of the ` TorchJD ` repo, run:
29- ``` bash
30- uv python install 3.14.0
31- uv python pin 3.14.0
32- ```
26+ ### Using the devcontainer
3327
34- 2 ) Create a virtual environment and install the project in it. From the root of ` TorchJD ` , run:
28+ 1 . Install [ Docker] ( https://docs.docker.com/get-docker/ ) and
29+ [ VS Code] ( https://code.visualstudio.com/ ) with the
30+ [ Dev Containers extension] ( https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers ) .
31+ 2 . Clone the repository and open it in VS Code:
3532 ``` bash
36- uv venv
37- CC=gcc uv pip install --python-version=3.14 -e ' .[full]' --group check --group doc --group test --group plot
38- ```
39- If you want to install PyTorch with a different CUDA version (this could be required depending on
40- your GPU), you'll need to specify an extra index. For instance, for CUDA 12.6, run:
41- ``` bash
42- uv venv
43- CC=gcc uv pip install --python-version=3.14 -e ' .[full]' --group check --group doc --group test --group plot --index-strategy unsafe-best-match --extra-index-url https://download.pytorch.org/whl/cu126
33+ git clone https://github.com/SimplexLab/TorchJD.git
34+ code TorchJD
4435 ```
36+ 3 . When prompted, click ** "Reopen in Container"** (or press ` Ctrl+Shift+P ` and run
37+ * "Dev Containers: Reopen in Container"* ). The container will build on first launch and install all
38+ dependencies automatically.
4539
46- 3 ) Set environment variables:
40+ Alternatively, you can use ** [ GitHub Codespaces] ( https://github.com/features/codespaces ) ** directly
41+ from the repository page — no local setup required.
4742
48- We need to use ` UV_NO_SYNC=1 ` to prevent ` uv ` from syncing all the time. This is because by
49- default, it tries to resolve libraries compatible with the whole range of Python versions
50- supported by TorchJD, but in reality, we just need an installation compatible with the currently
51- used Python version. That's also why we specify ` --python-version=3.14 ` when running
52- ` uv pip install ` . To follow that recommendation, add the following line to your ` .bashrc ` :
53- ``` bash
54- export UV_NO_SYNC=1
55- ```
56- and start a new terminal. The alternative is to use the ` --no-sync ` flag whenever you run a pip
57- command that would normally sync (like ` uv run ` ).
43+ The devcontainer includes:
44+ - Python 3.14 with all TorchJD dependencies (including optional ones)
45+ - All development tools: ` uv ` , ` ruff ` , ` ty ` , ` pre-commit ` , ` pytest `
46+ - Pre-configured VS Code extensions and settings
47+ - ` PYTHONPATH ` set up for the ` tests/ ` folder
5848
59- Lastly, to run some scripts from the ` tests ` folder, you'll have to add the ` TorchJD/tests `
60- folder to your ` PYTHONPATH ` . For that, you should add the following line to your ` .bashrc ` :
61- ``` bash
62- export PYTHONPATH=" $PYTHONPATH :<path_to_TorchJD>/tests"
63- ```
64- where ` <path_to_TorchJD> ` is the absolute path to your ` TorchJD ` repo.
49+ ### GPU support
6550
66- 4 ) Install pre-commit:
67- ``` bash
68- uv run pre-commit install
69- ```
51+ If you have an NVIDIA GPU and want to run tests on CUDA, add the following to
52+ ` .devcontainer/devcontainer.json ` inside the top-level object:
53+ ``` json
54+ "runArgs" : [" --gpus" , " all" ]
55+ ```
7056
71- > [ !TIP]
72- > If you're running into issues when ` uv ` tries to compile ` ecos ` , make sure that ` gcc ` is
73- > installed. Alternatively, you can try to install ` clang ` or try to use some older Python version
74- > (3.12) for which ` ecos ` has provided compiled packages (the list is accessible
75- > [ here] ( https://pypi.org/project/ecos/#files ) ).
57+ ### CUDA-specific PyTorch installation
7658
77- > [ !TIP]
78- > The Python version that you should specify in your IDE is ` <path-to-TorchJD>/.venv/bin/python ` .
59+ By default, the devcontainer installs the CPU-only version of PyTorch. If you need a CUDA version,
60+ run the following inside the container:
61+ ``` bash
62+ uv pip install --python-version=3.14 -e ' .[full]' --group check --group doc --group test --group plot --index-strategy unsafe-best-match --extra-index-url https://download.pytorch.org/whl/cu126
63+ ```
64+ (replace ` cu126 ` with your CUDA version).
65+
66+ ### Adding LaTeX (for trajectory plotting)
67+
68+ The trajectory plotting scripts require LaTeX. Install it inside the container with:
69+ ``` bash
70+ sudo apt-get update && sudo apt-get install -y texlive-latex-extra texlive-fonts-recommended dvipng cm-super
71+ ```
72+
73+ ### Manual setup (without devcontainer)
74+
75+ If you prefer a local setup, you'll need:
76+ - [ uv] ( https://docs.astral.sh/uv/getting-started/installation/ )
77+ - Python 3.14 (install via ` uv python install 3.14.0 ` )
78+ - ` gcc ` (for compiling ` ecos ` )
79+
80+ Then, from the repo root:
81+ ``` bash
82+ uv venv
83+ CC=gcc uv pip install --python-version=3.14 -e ' .[full]' --group check --group doc --group test --group plot
84+ export UV_NO_SYNC=1
85+ export PYTHONPATH=" $PYTHONPATH :$PWD /tests"
86+ uv run pre-commit install
87+ ```
7988
8089> [ !TIP]
8190> In the following commands, you can get rid of the ` uv run ` prefix if you activate the ` venv `
@@ -85,13 +94,12 @@ suggest to use VSCode with the `Python`, `ty` and `ruff` extensions (without `Py
8594
8695### Clean reinstallation
8796
88- If you want to update all dependencies or just reinstall from scratch, run the following command
89- from the root of ` TorchJD ` :
97+ If you want to update all dependencies or just reinstall from scratch, run the following inside the
98+ container :
9099``` bash
91- rm -rf .venv
92- rm -f uv.lock
93- uv venv
94- CC=gcc uv pip install --python-version=3.14 -e ' .[full]' --group check --group doc --group test --group plot
100+ rm -rf /opt/venv
101+ uv venv /opt/venv
102+ uv pip install --python-version=3.14 -e ' .[full]' --group check --group doc --group test --group plot
95103uv run pre-commit install
96104```
97105
0 commit comments