Compare commits

...

5 Commits

Author SHA1 Message Date
Joseph Hopfmüller
939a511625 add installation notes for CUDA 12.4, pyenv, and PyTorch; include useful links 2024-11-16 00:03:43 +01:00
Joseph Hopfmüller
2bf47dc0c0 more precise clone instructions 2024-11-15 23:54:33 +01:00
Joseph Hopfmüller
5871c79501 update README with cloning notes and adjust path in _path_fix.py for submodule import 2024-11-15 21:21:50 +01:00
Joseph Hopfmüller
f7217a93bb add pypho as submodule 2024-11-15 21:00:19 +01:00
Joseph Hopfmüller
5e2d3dd6b7 change pypho symlink to submodule and handle new location in _path_fix.py 2024-11-15 20:56:34 +01:00
10 changed files with 172 additions and 10 deletions

1
.gitignore vendored
View File

@@ -1,5 +1,4 @@
src/**/*.ini src/**/*.ini
pypho
# VSCode # VSCode
.vscode .vscode

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "pypho"]
path = pypho
url = git@gitlab.lrz.de:000000003B9B3E61/pypho.git

View File

@@ -13,10 +13,19 @@ Full license text in LICENSE file
# optical-regeneration # optical-regeneration
This repo has about 7.5GB of datasets in it. The download will take a while. ## Notes on cloning:
- `pypho` is added as a submodule -> `--recurse-submodules`
- This repo has about 7.5GB of datasets in it. The `git lfs fetch` step will take a while.
```bash ```bash
git clone https://git.suuppl.dev/seppl/optical-regeneration.git apt install git-lfs
# only necessary once per user account
git lfs install
git clone --recurse-submodules https://git.suuppl.dev/seppl/optical-regeneration.git && cd optical-regeneration
git lfs fetch
git lfs checkout
``` ```
## License ## License

View File

@@ -0,0 +1,74 @@
# CUDA 12.4 Install
> https://unknowndba.blogspot.com/2024/04/cuda-getting-started-on-wsl.html (@\_freddenis\_, 2024)
```bash
# get md5sums
wget https://developer.download.nvidia.com/compute/cuda/12.4.1/docs/sidebar/md5sum.txt
#
# setup cuda apt repo
wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
#
# download installer and check md5sum
wget https://developer.download.nvidia.com/compute/cuda/12.4.1/local_installers/cuda-repo-wsl-ubuntu-12-4-local_12.4.1-1_amd64.deb
md5sum --check --ignore-missing md5sum.txt
#
# try to install cuda (this will fail, but it puts the keyring file in the correct spot)
sudo dpkg -i cuda-repo-wsl-ubuntu-12-4-local_12.4.1-1_amd64.deb
#
# copy cuda gpg keyring to keyrings
sudo cp /var/cuda-repo-wsl-ubuntu-12-4-local/cuda-*-keyring.gpg /usr/share/keyrings/
#
# install cuda (this time for real)
sudo dpkg -i cuda-repo-wsl-ubuntu-12-4-local_12.4.1-1_amd64.deb
#
# install cuda-toolkit
sudo apt update
sudo apt install cuda-toolkit-12-4
#
# setup path
# sudo apt install plocate
locate nvcc
# -> returns /usr/local/cuda-12.4
# add these lines to your .profile (.zshrc, ...)
#
# export PATH="/usr/local/cuda-12.4/bin:$PATH"
# export LD_LIBRARY_PATH="/usr/local/cuda-12.4/lib64:$LD_LIBRARY_PATH"
#
# after source-ing, check version of nvcc
nvcc -V
```
## check cuda installation with cuda samples
```bash
git clone https://github.com/NVIDIA/cuda-samples
cd cuda-samples/Samples/1_Utilities/deviceQuery
make
./devicequery
```
### if the cuda-toolkit install fails with unmet dependencies
>https://askubuntu.com/a/1493087 (jspinella, 2023, CC BY-SA 4.0)
1. Open the *new* file for storing the sources list
```bash
sudo nano /etc/apt/sources.list.d/ubuntu.sources
```
2. Paste in the following at the end of the file:
```raw
Types: deb
URIs: http://archive.ubuntu.com/ubuntu/
Suites: lunar
Components: universe
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
```
3. Save the file and run `sudo apt update` - now the install command for CUDA should work.

4
notes/links.md Normal file
View File

@@ -0,0 +1,4 @@
# useful links
- (Optuna)[https://optuna.org] Hyperparameter optimization framework
`pip install optuna`

46
notes/pyenv-install.md Normal file
View File

@@ -0,0 +1,46 @@
# pyenv install
## install
nice to have:
```bash
sudo apt install python-is-python3
```
```bash
curl https://pyenv.run | bash
```
## setup zsh
add the following to `.zshrc`:
```bash
export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
```
## pyenv install
prerequisites:
```bash
sudo apt update
sudo apt install build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev curl git \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev \
libffi-dev liblzma-dev python3-pip
```
install:
```bash
# using python 3.12.7 as an example
pyenv install 3.12.7
# optional
pyenv global 3.12.7
pyenv versions
```

25
notes/pytorch-install.md Normal file
View File

@@ -0,0 +1,25 @@
# pytorch install
## create venv
```bash
python -m venv ./.venv
source ./.venv/bin/activate
```
## install pytorch
> https://pytorch.org/get-started/locally/
```bash
pip install torch torchvision torchaudio
```
## test pytorch install
```python
import torch
x = torch.rand(5, 3)
print(x)
torch.cuda.is_available()
```

1
pypho Submodule

Submodule pypho added at 08d6dadf20

View File

@@ -3,7 +3,7 @@ from pathlib import Path
# hack to add the parent directory to the path -> pypho doesn't have to be installed as package # hack to add the parent directory to the path -> pypho doesn't have to be installed as package
parent_dir = Path(__file__).parent parent_dir = Path(__file__).parent
while not (parent_dir / "pypho").exists() and parent_dir != Path("/"): while not (parent_dir / "pypho" / "pypho").exists() and parent_dir != Path("/"):
parent_dir = parent_dir.parent parent_dir = parent_dir.parent
print(f"Adding '{parent_dir}' to 'sys.path' to enable import of '{parent_dir / 'pypho'}'") print(f"Adding '{parent_dir / "pypho"}' to 'sys.path' to enable import of '{parent_dir / 'pypho' / 'pypho'}'")
sys.path.append(str(parent_dir)) sys.path.append(str(parent_dir / "pypho"))

View File

@@ -387,7 +387,7 @@ def length_loop(config, lengths, incremental=False):
in_out_eyes(cfiber, cdata) in_out_eyes(cfiber, cdata)
def single_run_with_plot(config): def single_run_with_plot(config, save=True):
cfiber, cdata, noise, edfa = initialize_fiber_and_data(config) cfiber, cdata, noise, edfa = initialize_fiber_and_data(config)
mean_power_in = np.sum(pypho.functions.getpower_W(cdata.E_in)) mean_power_in = np.sum(pypho.functions.getpower_W(cdata.E_in))
@@ -405,6 +405,7 @@ def single_run_with_plot(config):
E_tmp = [{'E': cdata.E_out, 'noise': noise*(-cfiber.params.l*cfiber.params.alpha)}] E_tmp = [{'E': cdata.E_out, 'noise': noise*(-cfiber.params.l*cfiber.params.alpha)}]
E_tmp = edfa(E=E_tmp) E_tmp = edfa(E=E_tmp)
cdata.E_out = E_tmp[0]['E'] cdata.E_out = E_tmp[0]['E']
if save:
save_data(cdata, config) save_data(cdata, config)
in_out_eyes(cfiber, cdata) in_out_eyes(cfiber, cdata)
@@ -509,7 +510,7 @@ if __name__ == "__main__":
] ]
lengths.append(max(length_ranges)*10) lengths.append(max(length_ranges)*10)
length_loop(config, lengths) # length_loop(config, lengths)
# single_run_with_plot(config) single_run_with_plot(config, save=False)