Skip to content

Commit

Permalink
Merge pull request #40 from DKreuter/main
Browse files Browse the repository at this point in the history
fixing torch 2. and numpy 2. issues
  • Loading branch information
DKreuter authored Aug 8, 2024
2 parents cb47e4a + c1bb366 commit 8c8debc
Show file tree
Hide file tree
Showing 110 changed files with 27,241 additions and 3,121 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v3
Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ __pycache__/*

# Log folders
**/lightning_logs/**
**/fluid_logs/**
**/Multiscale/**
**/bosch/**
**/experiments/**
**/fluid_logs/**
# Project files
.ropeproject
.project
Expand Down Expand Up @@ -57,3 +57,4 @@ MANIFEST
.venv*/
.conda*/
_venv/
.env/
108 changes: 108 additions & 0 deletions 2.0.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done

## Package Plan ##

environment location: C:\python\torchphysics\_venv

added / updated specs:
- pytorch-lightning


The following packages will be downloaded:

package | build
---------------------------|-----------------
comm-0.2.1 | py310haa95532_0 15 KB defaults
debugpy-1.6.7 | py310hd77b12b_0 2.9 MB defaults
exceptiongroup-1.2.0 | py310haa95532_0 31 KB defaults
filelock-3.13.1 | py310haa95532_0 22 KB defaults
fsspec-2024.3.1 | py310haa95532_0 278 KB defaults
gmpy2-2.1.2 | py310h7f96b67_0 160 KB defaults
ipykernel-6.28.0 | py310haa95532_0 199 KB defaults
ipython-8.25.0 | py310haa95532_0 1.2 MB defaults
jupyter_client-7.1.2 | pyhd3eb1b0_0 93 KB defaults
jupyter_core-5.7.2 | py310haa95532_0 110 KB defaults
libuv-1.48.0 | h827c3e9_0 322 KB defaults
lightning-utilities-0.9.0 | py310haa95532_0 38 KB defaults
mpc-1.1.0 | h7edee0f_1 260 KB defaults
mpfr-4.0.2 | h62dcd97_1 1.5 MB defaults
mpir-3.0.0 | hec2e145_1 1.3 MB defaults
mpmath-1.3.0 | py310haa95532_0 834 KB defaults
networkx-3.3 | py310haa95532_0 2.5 MB defaults
numpy-1.26.4 | py310h055cbcc_0 11 KB defaults
numpy-base-1.26.4 | py310h65a83cf_0 8.6 MB defaults
openssl-1.1.1w | h2bbff1b_0 5.5 MB defaults
platformdirs-3.10.0 | py310haa95532_0 36 KB defaults
prompt-toolkit-3.0.43 | py310haa95532_0 592 KB defaults
prompt_toolkit-3.0.43 | hd3eb1b0_0 5 KB defaults
pytorch-2.3.0 |cpu_py310h9432977_0 111.3 MB defaults
pytorch-lightning-2.3.0 | py310haa95532_0 874 KB defaults
pyyaml-6.0.1 | py310h2bbff1b_0 155 KB defaults
pyzmq-25.1.2 | py310hd77b12b_0 412 KB defaults
qtpy-2.4.1 | py310haa95532_0 127 KB defaults
sympy-1.12 | py310haa95532_0 10.5 MB defaults
torchmetrics-1.4.0.post0 | py310haa95532_0 698 KB defaults
tqdm-4.66.4 | py310h9909e9c_0 162 KB defaults
traitlets-5.14.3 | py310haa95532_0 182 KB defaults
typing-extensions-4.11.0 | py310haa95532_0 10 KB defaults
typing_extensions-4.11.0 | py310haa95532_0 62 KB defaults
------------------------------------------------------------
Total: 150.9 MB

The following NEW packages will be INSTALLED:

blas artifactory/anaconda-pkgs-remote/main/win-64::blas-1.0-mkl
comm artifactory/anaconda-pkgs-remote/main/win-64::comm-0.2.1-py310haa95532_0
exceptiongroup artifactory/anaconda-pkgs-remote/main/win-64::exceptiongroup-1.2.0-py310haa95532_0
filelock artifactory/anaconda-pkgs-remote/main/win-64::filelock-3.13.1-py310haa95532_0
fsspec artifactory/anaconda-pkgs-remote/main/win-64::fsspec-2024.3.1-py310haa95532_0
gmpy2 artifactory/anaconda-pkgs-remote/main/win-64::gmpy2-2.1.2-py310h7f96b67_0
intel-openmp artifactory/anaconda-pkgs-remote/main/win-64::intel-openmp-2023.1.0-h59b6b97_46320
ipykernel artifactory/anaconda-pkgs-remote/main/win-64::ipykernel-6.28.0-py310haa95532_0
ipython artifactory/anaconda-pkgs-remote/main/win-64::ipython-8.25.0-py310haa95532_0
jupyter_client artifactory/anaconda-pkgs-remote/main/noarch::jupyter_client-7.1.2-pyhd3eb1b0_0
libsodium artifactory/anaconda-pkgs-remote/main/win-64::libsodium-1.0.18-h62dcd97_0
libuv artifactory/anaconda-pkgs-remote/main/win-64::libuv-1.48.0-h827c3e9_0
lightning-utiliti~ artifactory/anaconda-pkgs-remote/main/win-64::lightning-utilities-0.9.0-py310haa95532_0
mkl artifactory/anaconda-pkgs-remote/main/win-64::mkl-2023.1.0-h6b88ed4_46358
mkl-service artifactory/anaconda-pkgs-remote/main/win-64::mkl-service-2.4.0-py310h2bbff1b_1
mkl_fft artifactory/anaconda-pkgs-remote/main/win-64::mkl_fft-1.3.8-py310h2bbff1b_0
mkl_random artifactory/anaconda-pkgs-remote/main/win-64::mkl_random-1.2.4-py310h59b6b97_0
mpc artifactory/anaconda-pkgs-remote/main/win-64::mpc-1.1.0-h7edee0f_1
mpfr artifactory/anaconda-pkgs-remote/main/win-64::mpfr-4.0.2-h62dcd97_1
mpir artifactory/anaconda-pkgs-remote/main/win-64::mpir-3.0.0-hec2e145_1
mpmath artifactory/anaconda-pkgs-remote/main/win-64::mpmath-1.3.0-py310haa95532_0
networkx artifactory/anaconda-pkgs-remote/main/win-64::networkx-3.3-py310haa95532_0
numpy artifactory/anaconda-pkgs-remote/main/win-64::numpy-1.26.4-py310h055cbcc_0
numpy-base artifactory/anaconda-pkgs-remote/main/win-64::numpy-base-1.26.4-py310h65a83cf_0
platformdirs artifactory/anaconda-pkgs-remote/main/win-64::platformdirs-3.10.0-py310haa95532_0
psutil artifactory/anaconda-pkgs-remote/main/win-64::psutil-5.9.0-py310h2bbff1b_0
pytorch artifactory/anaconda-pkgs-remote/main/win-64::pytorch-2.3.0-cpu_py310h9432977_0
pytorch-lightning artifactory/anaconda-pkgs-remote/main/win-64::pytorch-lightning-2.3.0-py310haa95532_0
pyyaml artifactory/anaconda-pkgs-remote/main/win-64::pyyaml-6.0.1-py310h2bbff1b_0
pyzmq artifactory/anaconda-pkgs-remote/main/win-64::pyzmq-25.1.2-py310hd77b12b_0
qtpy artifactory/anaconda-pkgs-remote/main/win-64::qtpy-2.4.1-py310haa95532_0
sympy artifactory/anaconda-pkgs-remote/main/win-64::sympy-1.12-py310haa95532_0
tbb artifactory/anaconda-pkgs-remote/main/win-64::tbb-2021.8.0-h59b6b97_0
torchmetrics artifactory/anaconda-pkgs-remote/main/win-64::torchmetrics-1.4.0.post0-py310haa95532_0
tqdm artifactory/anaconda-pkgs-remote/main/win-64::tqdm-4.66.4-py310h9909e9c_0
yaml artifactory/anaconda-pkgs-remote/main/win-64::yaml-0.2.5-he774522_0
zeromq artifactory/anaconda-pkgs-remote/main/win-64::zeromq-4.3.5-hd77b12b_0

The following packages will be UPDATED:

ca-certificates 2022.6.15-boschca_h5b45459_0 --> 2024.7.4-boschca_h56e8100_0
certifi bosch-ca-injected/win-64::certifi-202~ --> bosch-ca-injected/noarch::certifi-2024.7.4-boschca_pyhd8ed1ab_0
debugpy 1.5.1-py310hd77b12b_0 --> 1.6.7-py310hd77b12b_0
jupyter_core 4.10.0-py310haa95532_0 --> 5.7.2-py310haa95532_0
openssl 1.1.1p-h2bbff1b_0 --> 1.1.1w-h2bbff1b_0
prompt-toolkit artifactory/anaconda-pkgs-remote/main~ --> artifactory/anaconda-pkgs-remote/main/win-64::prompt-toolkit-3.0.43-py310haa95532_0
prompt_toolkit 3.0.20-hd3eb1b0_0 --> 3.0.43-hd3eb1b0_0
traitlets artifactory/anaconda-pkgs-remote/main~ --> artifactory/anaconda-pkgs-remote/main/win-64::traitlets-5.14.3-py310haa95532_0
typing-extensions artifactory/anaconda-pkgs-remote/main~ --> artifactory/anaconda-pkgs-remote/main/win-64::typing-extensions-4.11.0-py310haa95532_0
typing_extensions artifactory/anaconda-pkgs-remote/main~ --> artifactory/anaconda-pkgs-remote/main/win-64::typing_extensions-4.11.0-py310haa95532_0
vs2015_runtime 14.27.29016-h5e58377_2 --> 14.29.30133-h43f2093_4


Proceed ([y]/n)?
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ Contributors

* Nick Heilenkötter, nheilenkoetter <[email protected]>
* Tom Freudenberg, TomF98 <[email protected]>
* Daniel Kreuter, dkreuter <[email protected]>
22 changes: 8 additions & 14 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,35 +80,29 @@ Installation
============
TorchPhysics reqiueres the follwing dependencies to be installed:

- PyTorch_ >= 1.7.1, < 2.0.0
- `PyTorch Lightning`_ >= 1.3.4, < 2.0.0
- Numpy_ >= 1.20.2
- Python >= 3.8
- PyTorch_ >= 2.0.0
- `PyTorch Lightning`_ >= 2.0.0
- Numpy_ >= 1.20.2, < 2.0
- Matplotlib_ >= 3.0.0
- Scipy_ >= 1.6.3

Installing TorchPhysics with ``pip``, automatically downloads everything that is needed:
To install TorchPhysics you can run the following code in any Python environment where ``pip`` is installed

.. code-block:: python
pip install torchphysics
Additionally, to use the ``Shapely`` and ``Trimesh`` functionalities, install the library
with the option ``all``:

.. code-block:: python
pip install torchphysics[all]
If you want to add functionalities or modify the code. We recommend copying the
repository and installing it locally:
Or by

.. code-block:: python
git clone https://github.com/boschresearch/torchphysics
cd path_to_torchphysics_folder
pip install .[all]
if you want to modify the code.

.. _Numpy: https://numpy.org/
.. _Matplotlib: https://matplotlib.org/
.. _Scipy: https://scipy.org/
Expand Down
4 changes: 2 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ protobuf~=3.19.0 # fix github test and docu creation
sphinx>=3.2.1
sphinx_rtd_theme

torch>=1.7.1
pytorch-lightning>=1.3.4
torch>=2.0.0
pytorch-lightning>=2.0.0
numpy>=1.20.2
matplotlib>=3.4.2
trimesh>=3.9.19
Expand Down
11 changes: 6 additions & 5 deletions docs/tutorial/solve_pde.rst
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,12 @@ Afterwards we switch to LBFGS:
solver = tp.solver.Solver(train_conditions=[bound_cond, pde_cond], optimizer_setting=optim)
trainer = pl.Trainer(gpus=1,
max_steps=3000, # number of training steps
logger=False,
benchmark=True,
checkpoint_callback=False)
trainer = pl.Trainer(devices=1, accelerator="gpu",
num_sanity_val_steps=0,
benchmark=True,
max_steps=3000,
logger=False,
enable_checkpointing=False)
trainer.fit(solver)
Expand Down
15 changes: 10 additions & 5 deletions docs/tutorial/solver_info.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,20 @@ the basic trainer is defined as follows:
import pytorch_lightning as pl
trainer = pl.Trainer(gpus=1, max_steps=4000, check_val_every_n_epoch=10)
trainer = pl.Trainer(devices=1, accelerator="gpu",
max_steps=4000, check_val_every_n_epoch=10)
trainer.fit(solver) # start training
Some important keywords are:

- **gpus**: The number of GPUs that should be used. If only one or more CPUs are available
set ```gpus=None``. Depending on the operating system, the GPUs may have to be further
specified beforehand via ``os.environ`` or other ways. There are more different possiblities to
specify the used device, see the above mentionde documentation.
- **devices**: The number of devices that should be used.
- **accelerator**: On what kind of device the network will be trained.
Usually, one needs at least one GPU to train a neural network sufficiently well. If only
CPUs are available set ``"cpu"``.
Depending on the operating system, the GPUs may have to be further
specified beforehand via ``os.environ`` or other ways.
There are more different possibilities to specify the used device,
see the above-mentioned documentation.
- **max_steps**: The maximum number of training iterations. In each iteration
all defined training conditions will be evaluated
(e.g. points sampled, model output computed, residuals evaluated, etc.) and a
Expand Down
18 changes: 8 additions & 10 deletions examples/deeponet/inverse_ode.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,12 @@
"\n",
"solver = tp.solver.Solver([data_condition], optimizer_setting=optim)\n",
"\n",
"trainer = pl.Trainer(gpus='-1' if torch.cuda.is_available() else None,\n",
"trainer = pl.Trainer(devices=1, accelerator=\"gpu\",\n",
" num_sanity_val_steps=0,\n",
" benchmark=True,\n",
" max_steps=10000,\n",
" logger=False,\n",
" checkpoint_callback=False\n",
" )\n",
" max_steps=10000, \n",
" logger=False, \n",
" enable_checkpointing=False)\n",
"\n",
"trainer.fit(solver)"
]
Expand Down Expand Up @@ -327,13 +326,12 @@
"\n",
"solver = tp.solver.Solver([data_condition], optimizer_setting=optim)\n",
"\n",
"trainer = pl.Trainer(gpus='-1' if torch.cuda.is_available() else None,\n",
"trainer = pl.Trainer(devices=1, accelerator=\"gpu\",\n",
" num_sanity_val_steps=0,\n",
" benchmark=True,\n",
" max_steps=1000,\n",
" logger=False,\n",
" checkpoint_callback=False\n",
" )\n",
" max_steps=1000, \n",
" logger=False, \n",
" enable_checkpointing=False)\n",
"\n",
"trainer.fit(solver)"
]
Expand Down
18 changes: 9 additions & 9 deletions examples/deeponet/ode.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,12 @@
"\n",
"solver = tp.solver.Solver([ode_cond, initial_cond], optimizer_setting=optim)\n",
"\n",
"trainer = pl.Trainer(gpus='-1' if torch.cuda.is_available() else None,\n",
"trainer = pl.Trainer(devices=1, accelerator=\"gpu\",\n",
" num_sanity_val_steps=0,\n",
" benchmark=True,\n",
" max_steps=5000,\n",
" logger=False,\n",
" checkpoint_callback=False\n",
" )\n",
" max_steps=5000, \n",
" logger=False, \n",
" enable_checkpointing=False)\n",
"\n",
"trainer.fit(solver)"
]
Expand Down Expand Up @@ -284,11 +283,12 @@
"\n",
"solver = tp.solver.Solver(train_conditions=[ode_cond, initial_cond], optimizer_setting=optim)\n",
"\n",
"trainer = pl.Trainer(gpus=1,\n",
" max_steps=3000, \n",
" logger=False,\n",
"trainer = pl.Trainer(devices=1, accelerator=\"gpu\",\n",
" num_sanity_val_steps=0,\n",
" benchmark=True,\n",
" checkpoint_callback=False)\n",
" max_steps=3000, \n",
" logger=False, \n",
" enable_checkpointing=False)\n",
" \n",
"trainer.fit(solver)"
]
Expand Down
25 changes: 12 additions & 13 deletions examples/deeponet/oscillator.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"source": [
"import os\n",
"os.environ[\"CUDA_VISIBLE_DEVICES\"] = \"3\"\n",
"import torch\n",
"import torchphysics as tp\n",
"import torch\n",
"import pytorch_lightning as pl"
]
},
Expand Down Expand Up @@ -219,13 +219,12 @@
"source": [
"solver = tp.solver.Solver([ode_cond])\n",
"\n",
"trainer = pl.Trainer(gpus='-1' if torch.cuda.is_available() else None,\n",
"trainer = pl.Trainer(devices=1, accelerator=\"gpu\",\n",
" num_sanity_val_steps=0,\n",
" benchmark=True,\n",
" max_steps=2000,\n",
" logger=False,\n",
" checkpoint_callback=False\n",
" )\n",
" max_steps=30000, \n",
" logger=False, \n",
" enable_checkpointing=False)\n",
"\n",
"trainer.fit(solver)"
]
Expand Down Expand Up @@ -311,12 +310,12 @@
"\n",
"solver = tp.solver.Solver(train_conditions=[ode_cond], optimizer_setting=optim)\n",
"\n",
"trainer = pl.Trainer(gpus=1,\n",
" max_steps=2500, \n",
" logger=False,\n",
"trainer = pl.Trainer(devices=1, accelerator=\"gpu\",\n",
" num_sanity_val_steps=0,\n",
" benchmark=True,\n",
" checkpoint_callback=False)\n",
" \n",
" max_steps=2500, \n",
" logger=False, \n",
" enable_checkpointing=False)\n",
"trainer.fit(solver)"
]
},
Expand Down Expand Up @@ -454,10 +453,10 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.15"
"version": "3.11.7"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
}
Loading

0 comments on commit 8c8debc

Please sign in to comment.