Skip to content

Commit

Permalink
cuda downgrade 11.7
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsenhariri committed Nov 11, 2023
1 parent 5ee90cd commit ed47359
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 226 deletions.
157 changes: 21 additions & 136 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,139 +3,24 @@
A [simple] [general-purpose] Python template 🐍🚀🎉🦕


I used this template for [fesenjoon](https://pypi.org/project/fesenjoon/) and [medviz](https://pypi.org/project/medviz/).

## How to use

- Linux and Mac
Use GCC Makefile

- Install Makefile

https://community.chocolatey.org/packages/make

http://www.cygwin.com/

### Bootstrap

To use env in another directory:

``` bash
make env
```

There is no need to active virtual environment when the `PY` command is used from Makefile.

To use env here (local directory)

``` bash
make env-local
```

``` bash
source env_platform_ver/bin/activate
```

Set a name for the package:

```bash
make init newName
```

Check Python and pip version

``` bash
make
```

Update pip and build tools

``` bash
make check
```

Install the requirements

``` bash
make pireq
```

### Install a package

``` bash
make piu numpy matplotlib scipy
```

## Features

- Linter: Pylint
- Formatter: Black
- CI: GitHub Actions

### ToDo

- [x] Formatter: Black + isort
- [x] Type checker: MyPy
- [x] Linter: Ruff
- [x] Linter: Pylint
- [x] GitHub Actions
- [x] Git Hooks
- [x] PyPI Publish
- [x] Flit
- [x] Poetry
- [x] Ruff

### Git

Git hooks are available in ./scripts/.githooks

``` bash
chmod +x ./scripts/.githooks/script

git config core.hooksPath ./scripts/.githooks

```


## Publish to PyPI


1. To build a package, run:
``` bash
make pkg-build
```

2. To check the build, run:
``` bash
make pkg-check
```

3. To install the package locally, run:
``` bash
make pkg-install
```

4. Create `.pypirc` file in the root directory of the project. It should look like this:

``` bash
[distutils]
index-servers =
pypi
testpypi

[pypi]
repository: https://upload.pypi.org/legacy/
username: <your username>
password: <your password>

[testpypi]
repository: https://test.pypi.org/legacy/
username: <your username>
password: <your password>
```

4. To publish to PyPI, run:

``` bash
make pkg-publish
```
## Run on HPC

1. Clone the repository
```bash
git clone [email protected]:mohsenhariri/template-python.git
chmod -R u=rwx,go= template-python
cd template-python
```

2. Run the initialization script
```bash
chmod +x hpc.init
source hpc.init
```

3. Modify or add commands to `hpc.make` file

4. Run the `hpc.make` file
```bash
make newCommand
```
14 changes: 10 additions & 4 deletions hpc.init
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
echo "Job ID: $SLURM_JOB_ID"

module purge
module load Python/3.11.3-GCCcore-12.3.0
module load CUDA/12.0.0

module load Python/3.10.4-GCCcore-11.3.0
module load cuDNN/8.4.1.50-CUDA-11.7.0

DIRNAME="$(basename "$(pwd)")"

Expand All @@ -17,7 +18,12 @@ make switch-env hpc
make env-local
make test
make check
make pia

# install all dependencies available in requirements.txt
make pia
# Run Makefile targets
make run
make run

# install pytorch
# make piu install torch torchvision --index-url https://download.pytorch.org/whl/cu117
make gpu-test
5 changes: 4 additions & 1 deletion hpc.make
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
run:
$(PY) $(SRC)/app.py
$(PY) $(SRC)/app.py

gpu-test:
$(PY) $(SRC)/gpu.py
2 changes: 1 addition & 1 deletion pkg/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
DocString
"""
print("main")
print("Running on HPC")
8 changes: 0 additions & 8 deletions pkg/args.py

This file was deleted.

6 changes: 6 additions & 0 deletions pkg/gpu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import torch

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

print(f"Using {device} device")
print(f"Using {torch.cuda.device_count()} GPUs!")
12 changes: 0 additions & 12 deletions pkg/sample.py

This file was deleted.

27 changes: 0 additions & 27 deletions pkg/test_app.py

This file was deleted.

4 changes: 0 additions & 4 deletions pkg/utility/custom_type.py

This file was deleted.

33 changes: 0 additions & 33 deletions pkg/utility/reader.py

This file was deleted.

0 comments on commit ed47359

Please sign in to comment.