Skip to content

Commit

Permalink
Update TensorFlow to 2.10 (#1)
Browse files Browse the repository at this point in the history
* Attempt 1 out of np.inf at building TF

* Fix path to requirements

* Maybe maybe maybe

* Clean up
  • Loading branch information
talmo authored Mar 18, 2024
1 parent 7e585d4 commit 0381d3a
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 56 deletions.
9 changes: 1 addition & 8 deletions .conda.tensorflow/bld.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,4 @@ set PIP_NO_INDEX=False
set PIP_NO_DEPENDENCIES=False
set PIP_IGNORE_INSTALLED=False

rem pip install numpy==1.21.5
rem pip install numpy==1.19.5
pip install tensorflow==2.6.3
pip install tensorboard==2.6.0
rem pip install h5py==3.1.0
pip install opencv-python-headless==4.5.5.62
pip install git+https://github.com/talmolab/wrap_opencv-python-headless.git@ede49f6a23a73033216339f29515e59d594ba921
pip install setuptools-scm
pip install --no-cache-dir -r .\requirements.tensorflow.txt
17 changes: 9 additions & 8 deletions .conda.tensorflow/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ export PIP_NO_INDEX=False
export PIP_NO_DEPENDENCIES=False
export PIP_IGNORE_INSTALLED=False

# pip install numpy==1.21.5
# pip install numpy==1.19.5
pip install tensorflow==2.6.3
pip install tensorboard==2.6.0
# pip install h5py==3.1.0
pip install opencv-python-headless==4.5.5.62
pip install git+https://github.com/talmolab/wrap_opencv-python-headless.git@ede49f6a23a73033216339f29515e59d594ba921
pip install setuptools-scm
pip install --no-cache-dir -r ./requirements.tensorflow.txt

# Copy the activate scripts to $PREFIX/etc/conda/activate.d.
# This will allow them to be run on environment activation.
for CHANGE in "activate" "deactivate"
do
mkdir -p "${PREFIX}/etc/conda/${CHANGE}.d"
cp "${RECIPE_DIR}/tensorflow_${CHANGE}.sh" "${PREFIX}/etc/conda/${CHANGE}.d/tensorflow_${CHANGE}.sh"
done
20 changes: 6 additions & 14 deletions .conda.tensorflow/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@

package:
name: tensorflow
version: 2.6.3
version: 2.10.1

about:
home: https://tensorflow.org
license: Apache License
summary: 'TensorFlow conda package based on the PyPI wheels.
Also includes numpy and opencv-python-headless.
For GPU support, install cudatoolkit 11.3.1 and cudnn 8.2.1 which are available as conda packages on the default channel.'

build:
number: 2
number: 0

source:
path: ../

requirements:
build:
Expand All @@ -23,21 +24,12 @@ requirements:

host:
- python=3.7
- conda-forge::numpy=1.19.5
- conda-forge::h5py=3.1.0
- conda-forge::scipy=1.7.3
- pip

run:
- python=3.7
- conda-forge::numpy~=1.19.5
- conda-forge::h5py~=3.1.0
- conda-forge::scipy>=1.4.1,<=1.7.3
- pip

test:
imports:
- tensorflow
- numpy
- h5py
- cv2
- tensorflow
6 changes: 6 additions & 0 deletions .conda.tensorflow/tf_activate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

# Remember the old library path for when we deactivate
export SLEAP_OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
# Help CUDA find GPUs!
export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH
4 changes: 4 additions & 0 deletions .conda.tensorflow/tf_deactivate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

# Reset to the old library path for when deactivating the environment
export LD_LIBRARY_PATH=$SLEAP_OLD_LD_LIBRARY_PATH
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,6 @@ dmypy.json

# Pyre type checker
.pyre/


build.*/
32 changes: 11 additions & 21 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,32 @@

![Build TensorFlow](https://github.com/talmo/conda_packages/workflows/Build%20TensorFlow/badge.svg) [![TensorFlow package](https://anaconda.org/sleap/tensorflow/badges/platforms.svg)](https://anaconda.org/sleap/tensorflow)

![Build PySide2](https://github.com/talmo/conda_packages/workflows/Build%20PySide2/badge.svg) [![PySide2 package](https://anaconda.org/sleap/pyside2/badges/platforms.svg)](https://anaconda.org/sleap/pyside2)

---

This repository contains conda build recipes and GitHub Actions workflows for building some common pip dependencies.

This serves primarily to support [SLEAP](https://sleap.ai) ([`murthylab/sleap`](https://github.com/murthylab/sleap)) by keeping big dependencies in a separate conda package rather than packaging them with SLEAP every time.
This serves primarily to support [SLEAP](https://sleap.ai) ([`talmolab/sleap`](https://github.com/talmolab/sleap)) by keeping big dependencies in a separate conda package rather than packaging them with SLEAP every time.

The packages can be browsed online at the [Anaconda sleap channel](https://anaconda.org/sleap/repo).

To install the compiled packages, just specify the channel, for example:
**Note**: Packages are built for Python 3.7.

- Create a new environment: `conda create -c sleap -n my_env tensorflow=2.7.0`
- Install in existing environment: `conda install -c sleap tensorflow=2.7.0`
- Include in a `environment.yml` dependencies section: `sleap::tensorflow=2.7.0`
To install the compiled packages, just specify the channel, for example:

The `sleap/tensorflow` package includes the following libraries packaged from pip wheels:
- `numpy==1.19.5`
- `tensorflow==2.7.0`
- `tensorboard==2.7.0`
- `h5py==3.1.0`
- `opencv-python-headless==4.2.0.34`
- Create a new environment: `conda create -c sleap -n my_env tensorflow=2.10.1`
- Install in existing environment: `conda install -c sleap tensorflow=2.10.1`
- Include in a `environment.yml` dependencies section: `sleap::tensorflow=2.10.1`

This can be installed with or without GPU support since TensorFlow will now run in CPU mode if the CUDA drivers are not detected.

To enable GPU support, install CUDA Toolkit 11.3.1 and CuDNN 8.2.1. You can install these at the system level, or through existing conda packages:
- [`anaconda/cudatoolkit`](https://anaconda.org/anaconda/cudatoolkit)
- [`anaconda/cudnn`](https://anaconda.org/anaconda/cudnn)

## Quick install with GPU support

For PySide2 5.14.1, install using:

`conda install -c sleap pyside2=5.14.1`

or by adding this to your `environment.yml` dependencies:

`sleap::pyside2=5.14.1`
```
conda create -n my_env -c conda-forge -c nvidia -c sleap -c anaconda python=3.7 tensorflow=2.10 cudatoolkit=11.3 cudnn=8.2 cuda-nvcc=11.3
```

**Note**: Packages are built for Python 3.7.
This will create an environment called `my_env` with TensorFlow and GPU support.
6 changes: 1 addition & 5 deletions requirements.tensorflow.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
numpy>=1.19.5,<=1.21.5
tensorflow==2.6.3
tensorboard==2.6.0
h5py>=3.1.0,<=3.6.0
opencv-python-headless>=4.2.0.34,<=4.5.5.62
tensorflow==2.10.1

0 comments on commit 0381d3a

Please sign in to comment.