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

Various changes #549

Merged
merged 31 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
89d4eca
Change defaults python version
bwohlberg Aug 20, 2024
67f6445
Update docs for conda environment creation script
bwohlberg Aug 20, 2024
b1884c3
Recommend python 3.10 instead of 3.9
bwohlberg Aug 20, 2024
baf0329
Add note on python version requirement for jax
bwohlberg Aug 20, 2024
4928227
Update jax/gpu instructions
bwohlberg Aug 20, 2024
5134a85
Add note on availgpu.py script
bwohlberg Aug 20, 2024
7a63505
Move gpu util scripts
bwohlberg Aug 20, 2024
a51c435
Formatting fix
bwohlberg Aug 20, 2024
bc3b80a
Formatting fix
bwohlberg Aug 20, 2024
44a0dbb
Formatting fix
bwohlberg Aug 20, 2024
4c3a3da
Formatting fix
bwohlberg Aug 20, 2024
b3ec07a
Add readme files
bwohlberg Aug 20, 2024
1d01b7b
Minor phrasing improvement
bwohlberg Aug 20, 2024
116c1c8
Improve formatting
bwohlberg Aug 20, 2024
b231983
Avoid issues with ray and conda version of hyperopt
bwohlberg Aug 20, 2024
83c8e57
Python 3.7 no longer supported
bwohlberg Aug 20, 2024
2ab5771
Trivial edit
bwohlberg Aug 20, 2024
024c2b4
Address PR review comments
bwohlberg Sep 5, 2024
74840b9
Switch for Python 3.12 for CI
bwohlberg Sep 5, 2024
0e7c845
Attempt to resolve CI test failures
bwohlberg Sep 5, 2024
d8bf788
Attempt to resolve CI test failures
bwohlberg Sep 5, 2024
1ae98d9
Attempt to resolve CI test failures
bwohlberg Sep 5, 2024
047ed5f
Attempt to resolve CI test failures
bwohlberg Sep 5, 2024
71c6215
Attempt to resolve CI test failures
bwohlberg Sep 5, 2024
dc7f1ae
Attempt to resolve CI test failures
bwohlberg Sep 5, 2024
b1f2600
Fix yaml syntax error
bwohlberg Sep 5, 2024
368df35
Clean up
bwohlberg Sep 5, 2024
c7bb2b7
Add comment
bwohlberg Sep 5, 2024
1c79873
Address PR comments
bwohlberg Sep 5, 2024
4a06cca
Bump actions/cache version
bwohlberg Sep 5, 2024
b923298
Avoid use of mambaforge in response to deprecation warning
bwohlberg Sep 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/source/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Installing a Development Version
1. Fork both the ``scico`` and ``scico-data`` repositories, creating
copies of these repositories in your own git account.

2. Make sure that you have Python 3.8 or later installed in order to
2. Make sure that you have Python 3.10 or later installed in order to
create a conda virtual environment.

3. Clone your fork from the source repo.
Expand All @@ -26,11 +26,11 @@ Installing a Development Version

git clone --recurse-submodules [email protected]:<username>/scico.git

4. Create a conda environment using Python 3.8 or later, e.g.:
4. Create a conda environment using Python 3.10 or later, e.g.:

::

conda create -n scico python=3.9
conda create -n scico python=3.11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest conda create -n temp "python>=3.10,<3.13" as a more future-proof option.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe conda create -n scico python=3.10 if that really is the version that is most thoroughly tested.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to 3.12, which is the current stable version, and also the version tested in scico CI.


5. Activate the created conda virtual environment:

Expand Down
55 changes: 26 additions & 29 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,26 @@ Installing SCICO

SCICO requires Python version 3.8 or later. (Version 3.10 is
recommended as it is the version under which SCICO has been most
thoroughly tested.) It is supported on both Linux and MacOS, but is
not currently supported on Windows due to the limited support for
``jaxlib`` on Windows. However, Windows users can use SCICO via the
`Windows Subsystem for Linux
thoroughly tested, and is the minimum supported Python version for
the most recent versions of JAX.) It is supported on both Linux and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"It is supported..." -> "SCICO is supported"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

MacOS, but is not currently supported on Windows due to the limited
support for ``jaxlib`` on Windows. However, Windows users can use
SCICO via the `Windows Subsystem for Linux
<https://docs.microsoft.com/en-us/windows/wsl/about>`_ (WSL). Guides
exist for using WSL with `CPU only
<https://docs.microsoft.com/en-us/windows/wsl/install-win10>`_ and
with `GPU support
<https://docs.microsoft.com/en-us/windows/win32/direct3d12/gpu-cuda-in-wsl>`_.

While not required, installation of SCICO and its dependencies within a `Conda <https://conda.io/projects/conda/en/latest/user-guide/index.html>`_ environment
is recommended. `Scripts <https://github.com/lanl/scico/tree/main/misc/conda>`_
are provided for creating a `miniconda <https://docs.conda.io/en/latest/miniconda.html>`_ installation and an environment including all primary SCICO dependencies as well as dependencies
for usage example, testing, and building the documentation.
exist for using WSL with
`CPU only <https://docs.microsoft.com/en-us/windows/wsl/install-win10>`_
and with
`GPU support <https://docs.microsoft.com/en-us/windows/win32/direct3d12/gpu-cuda-in-wsl>`_.

While not required, installation of SCICO and its dependencies within a
`Conda <https://conda.io/projects/conda/en/latest/user-guide/index.html>`_
environment is recommended.
`Scripts <https://github.com/lanl/scico/tree/main/misc/conda>`_
are provided for creating a
`miniconda <https://docs.conda.io/en/latest/miniconda.html>`_
installation and an environment including all primary SCICO dependencies
as well as dependencies for usage example, testing, and building the
documentation.


From PyPI
Expand Down Expand Up @@ -108,31 +114,22 @@ a version with GPU support:
2. Install the version of jaxlib with GPU support, as described in the `JAX installation
instructions <https://jax.readthedocs.io/en/latest/installation.html>`_.
In the simplest case, the appropriate command is
::

pip install --upgrade "jax[cuda11]"

for CUDA 11, or
::

pip install --upgrade "jax[cuda12]"

for CUDA 12, but it may be necessary to explicitly specify the
``jaxlib`` version if the most recent release is not yet supported
by SCICO (as specified in the ``requirements.txt`` file), or if
using a version of CUDA older than 11.4, or CuDNN older than 8.2,
in which case the command would be of the form
::

pip install --upgrade "jaxlib==0.4.2+cuda11.cudnn82" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html

with appropriate substitution of ``jaxlib``, CUDA, and CuDNN version
numbers.
by SCICO (as specified in the ``requirements.txt`` file).


The script `misc/envinfo.py <https://github.com/lanl/scico/blob/main/misc/envinfo.py>`_
The script
`misc/gpu/envinfo.py <https://github.com/lanl/scico/blob/main/misc/gpu/envinfo.py>`_
in the source distribution is provided as an aid to debugging GPU support
issues.
issues. The script
`misc/gpu/availgpu.py <https://github.com/lanl/scico/blob/main/misc/gpu/availgpu.py>`_
can be used to automatically recommend a setting of the CUDA_VISIBLE_DEVICES
environment variable that excludes GPUs that are already in use.



Expand Down
6 changes: 5 additions & 1 deletion misc/README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Miscellaneous
=============

This directory is a temporary location for content for which there is no immediately obvious correct location.
This directory is a temporary location for content for which there is no
obviously more appropriate location:

- ``conda``: Scripts intended to faciliate the installation of miniconda and an environment with all SCICO requirements.
- ``gpu``: Scripts for debugging and managing JAX use of GPUs.
- ``pytest``: Scripts for specialized use of ``pytest``.
4 changes: 2 additions & 2 deletions misc/conda/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ To install miniconda in ``/opt/conda`` do
./install_conda.sh -y /opt/conda


To create a conda environment called ``py39`` with default Python version (3.9) and without GPU support
To create a conda environment called ``py310`` with default Python version (3.10) and without GPU support

::

./make_conda_env.sh -y -e py39
./make_conda_env.sh -y -e py310
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this env should be called scico to make it more consistent with docs/source/contributing.rst

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.



To include GPU support, follow the `jax installation instructions <https://github.com/google/jax#pip-installation-gpu-cuda>`__ after
Expand Down
9 changes: 6 additions & 3 deletions misc/conda/make_conda_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ Usage: $SCRIPT [-h] [-y] [-g] [-p python_version] [-e env_name]
[-v] Verbose operation
[-t] Display actions that would be taken but do nothing
[-y] Do not ask for confirmation
[-p python_version] Specify Python version (e.g. 3.9)
[-p python_version] Specify Python version (e.g. 3.10)
[-e env_name] Specify conda environment name
EOF
)

AGREE=no
VERBOSE=no
TEST=no
PYVER="3.9"
PYVER="3.10"
ENVNM=py$(echo $PYVER | sed -e 's/\.//g')

# Project requirements files
Expand All @@ -50,7 +50,7 @@ EOF
)
# Requirements that cannot be installed via conda (i.e. have to use pip)
NOCONDA=$(cat <<-EOF
flax bm3d bm4d py2jn colour_demosaicing ray[tune,train]
flax bm3d bm4d py2jn colour_demosaicing hyperopt ray[tune,train]
EOF
)

Expand Down Expand Up @@ -257,6 +257,9 @@ echo
echo "JAX installed without GPU support. To enable GPU support, install a"
echo "version of jaxlib with CUDA support following the instructions at"
echo " https://jax.readthedocs.io/en/latest/installation.html#nvidia-gpu"
echo "In most cases this just requires the command"
echo " pip install -U \"jax[cuda12]\""
echo
echo "ASTRA Toolbox installed without GPU support if this script was"
echo "run on a host without CUDA drivers installed. To enable GPU support,"
echo "uninstall and then reinstall the astra-toolbox conda package on a"
Expand Down
7 changes: 7 additions & 0 deletions misc/gpu/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
GPU Utility Scripts
===================

These scripts are intended for debugging and managing JAX use of GPUs:

- ``availgpu.py``: Automatically recommend a setting of the ``CUDA_VISIBLE_DEVICES`` environment variable that excludes GPUs that are already in use.
- ``envinfo.py``: An aid to debugging JAX GPU access.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions misc/pytest/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Specialized Pytest Usage
========================

These scripts support specialized ``pytest`` usage:

- ``pytest_cov.sh``: This script runs ``scico`` unit tests using the ``pytest-cov`` plugin for test coverage analysis.
- ``pytest_fast.sh``: This script runs ``pytest`` tests in parallel using the ``pytest-xdist`` plugin. Some tests (those that do not function correctly when run in parallel) are run separately.
- ``pytest_time.sh``: This script runs each ``scico`` unit test module and lists them all in order of decreasing run time.

All of these scripts must be run from the repository root directory.
13 changes: 2 additions & 11 deletions scico/_version.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2020-2022 by SCICO Developers
# Copyright (C) 2020-2024 by SCICO Developers
# All rights reserved. BSD 3-clause License.
# This file is part of the SCICO package. Details of the copyright and
# user license can be found in the 'LICENSE' file distributed with the
# package.

"""Support functions for determining the package version."""

import ast
import os
import re
import sys
from ast import parse
from subprocess import PIPE, Popen
from typing import Any, Optional, Tuple, Union
Expand Down Expand Up @@ -43,14 +41,7 @@ def variable_assign_value(path: str, var: str) -> Any:
try:
# See http://stackoverflow.com/questions/2058802
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could link directly to the answer used, which I think is https://stackoverflow.com/a/30471662

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

value_obj = parse(next(filter(lambda line: line.startswith(var), f))).body[0].value # type: ignore
if sys.version_info.major == 3 and sys.version_info.minor == 7:
if isinstance(value_obj, ast.Num):
value = value_obj.n # type: ignore
elif isinstance(value_obj, ast.Str):
value = value_obj.s # type: ignore
else:
value = value_obj.s # type: ignore

value = value_obj.value # type: ignore
except StopIteration:
raise RuntimeError(f"Could not find initialization of variable {var}")
return value
Expand Down
Loading