Skip to content

Commit

Permalink
Initial commit based on tag V0.5.3 from Nerfacc repository
Browse files Browse the repository at this point in the history
  • Loading branch information
Shakiba Kheradmand committed Nov 28, 2023
0 parents commit 76b1a44
Show file tree
Hide file tree
Showing 112 changed files with 13,027 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/aws/update_index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from collections import defaultdict

import boto3

ROOT_URL = 'https://nerfacc-bucket.s3.us-west-2.amazonaws.com/whl'
html = '<!DOCTYPE html>\n<html>\n<body>\n{}\n</body>\n</html>'
href = ' <a href="{}">{}</a><br/>'
args = {
'ContentType': 'text/html',
'CacheControl': 'max-age=300',
'ACL': 'public-read',
}

bucket = boto3.resource('s3').Bucket(name='nerfacc-bucket')

wheels_dict = defaultdict(list)
for obj in bucket.objects.filter(Prefix='whl'):
if obj.key[-3:] != 'whl':
continue
torch_version, wheel = obj.key.split('/')[-2:]
wheel = f'{torch_version}/{wheel}'
wheels_dict[torch_version].append(wheel)

index_html = html.format('\n'.join([
href.format(f'{torch_version}.html'.replace('+', '%2B'), version)
for version in wheels_dict
]))

with open('index.html', 'w') as f:
f.write(index_html)
bucket.Object('whl/index.html').upload_file('index.html', args)

for torch_version, wheel_names in wheels_dict.items():
torch_version_html = html.format('\n'.join([
href.format(f'{ROOT_URL}/{wheel_name}'.replace('+', '%2B'), wheel_name)
for wheel_name in wheel_names
]))

with open(f'{torch_version}.html', 'w') as f:
f.write(torch_version_html)
bucket.Object(f'whl/{torch_version}.html').upload_file(
f'{torch_version}.html', args)
176 changes: 176 additions & 0 deletions .github/workflows/building.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
name: Building Wheels

on: [workflow_dispatch]

jobs:

wheel:
runs-on: ${{ matrix.os }}
environment: production

strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-2019]
# support version based on: https://download.pytorch.org/whl/torch/
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
torch-version: [1.11.0, 1.12.0, 1.13.0, 2.0.0]
cuda-version: ['cu113', 'cu115', 'cu116', 'cu117', 'cu118']
exclude:
- torch-version: 1.11.0
python-version: '3.11'
- torch-version: 1.11.0
cuda-version: 'cu116'
- torch-version: 1.11.0
cuda-version: 'cu117'
- torch-version: 1.11.0
cuda-version: 'cu118'

- torch-version: 1.12.0
python-version: '3.11'
- torch-version: 1.12.0
cuda-version: 'cu115'
- torch-version: 1.12.0
cuda-version: 'cu117'
- torch-version: 1.12.0
cuda-version: 'cu118'

- torch-version: 1.13.0
cuda-version: 'cu102'
- torch-version: 1.13.0
cuda-version: 'cu113'
- torch-version: 1.13.0
cuda-version: 'cu115'
- torch-version: 1.13.0
cuda-version: 'cu118'

- torch-version: 2.0.0
python-version: '3.7'
- torch-version: 2.0.0
cuda-version: 'cu102'
- torch-version: 2.0.0
cuda-version: 'cu113'
- torch-version: 2.0.0
cuda-version: 'cu115'
- torch-version: 2.0.0
cuda-version: 'cu116'

- os: windows-2019
cuda-version: 'cu102'
- os: windows-2019
torch-version: 1.13.0
python-version: '3.11'

# - os: windows-2019
# torch-version: 1.13.0
# cuda-version: 'cu117'
# python-version: '3.9'



steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Upgrade pip
run: |
pip install --upgrade setuptools
pip install ninja
- name: Free up disk space
if: ${{ runner.os == 'Linux' }}
run: |
sudo rm -rf /usr/share/dotnet
- name: Install CUDA ${{ matrix.cuda-version }}
if: ${{ matrix.cuda-version != 'cpu' }}
run: |
bash .github/workflows/cuda/${{ runner.os }}.sh ${{ matrix.cuda-version }}
- name: Install PyTorch ${{ matrix.torch-version }}+${{ matrix.cuda-version }}
run: |
pip install torch==${{ matrix.torch-version }} --extra-index-url https://download.pytorch.org/whl/${{ matrix.cuda-version }}
python -c "import torch; print('PyTorch:', torch.__version__)"
python -c "import torch; print('CUDA:', torch.version.cuda)"
python -c "import torch; print('CUDA Available:', torch.cuda.is_available())"
- name: Patch PyTorch static constexpr on Windows
if: ${{ runner.os == 'Windows' }}
run: |
Torch_DIR=`python -c 'import os; import torch; print(os.path.dirname(torch.__file__))'`
sed -i '31,38c\
TORCH_API void lazy_init_num_threads();' ${Torch_DIR}/include/ATen/Parallel.h
shell: bash

- name: Set version
if: ${{ runner.os != 'macOS' }}
run: |
VERSION=`sed -n 's/^__version__ = "\(.*\)"/\1/p' nerfacc/version.py`
TORCH_VERSION=`echo "pt${{ matrix.torch-version }}" | sed "s/..$//" | sed "s/\.//g"`
CUDA_VERSION=`echo ${{ matrix.cuda-version }}`
echo "New version name: $VERSION+$TORCH_VERSION$CUDA_VERSION"
sed -i "s/$VERSION/$VERSION+$TORCH_VERSION$CUDA_VERSION/" nerfacc/version.py
shell:
bash

- name: Install main package for CPU
if: ${{ matrix.cuda-version == 'cpu' }}
run: |
BUILD_NO_CUDA=1 pip install .
- name: Build wheel
run: |
pip install wheel
source .github/workflows/cuda/${{ runner.os }}-env.sh ${{ matrix.cuda-version }}
python setup.py bdist_wheel --dist-dir=dist
shell: bash # `source` does not exist in windows powershell

- name: Test wheel
run: |
cd dist
ls -lah
pip install *.whl
python -c "import nerfacc; print('nerfacc:', nerfacc.__version__)"
cd ..
shell: bash # `ls -lah` does not exist in windows powershell

- name: Configure AWS
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2

- name: Upload wheel
run: |
aws s3 sync dist s3://nerfacc-bucket/whl/torch-${{ matrix.torch-version }}_${{ matrix.cuda-version }} --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers
update_aws_listing:
needs: [wheel]
runs-on: ubuntu-latest
environment: production

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Upgrade pip
run: |
pip install boto3
- name: Update AWS listing
run: |
python scripts/run_aws_listing.py \
--bucket="nerfacc-bucket" \
--region="us-west-2"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
31 changes: 31 additions & 0 deletions .github/workflows/code_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Core Tests.

on:
push:
branches: [master]
pull_request:
branches: [master]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8.12
uses: actions/setup-python@v4
with:
python-version: "3.8.12"
- name: Install dependencies
run: |
pip install isort==5.10.1 black[jupyter]==22.3.0
- name: Run isort
run: isort docs/ nerfacc/ scripts/ examples/ tests/ --profile black --skip examples/pycolmap --line-length 80 --check
- name: Run Black
run: black docs/ nerfacc/ scripts/ examples/ tests/ --exclude examples/pycolmap --line-length 80 --check
# - name: Python Pylint
# run: |
# pylint nerfacc/ tests/ scripts/ examples/
44 changes: 44 additions & 0 deletions .github/workflows/cuda/Linux-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# Took from https://github.com/pyg-team/pyg-lib/

case ${1} in
cu118)
export CUDA_HOME=/usr/local/cuda-11.8
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
export PATH=${CUDA_HOME}/bin:${PATH}
export TORCH_CUDA_ARCH_LIST="3.5;5.0+PTX;6.0;7.0;7.5;8.0;8.6"
;;
cu117)
export CUDA_HOME=/usr/local/cuda-11.7
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
export PATH=${CUDA_HOME}/bin:${PATH}
export TORCH_CUDA_ARCH_LIST="3.5;5.0+PTX;6.0;7.0;7.5;8.0;8.6"
;;
cu116)
export CUDA_HOME=/usr/local/cuda-11.6
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
export PATH=${CUDA_HOME}/bin:${PATH}
export TORCH_CUDA_ARCH_LIST="3.5;5.0+PTX;6.0;7.0;7.5;8.0;8.6"
;;
cu115)
export CUDA_HOME=/usr/local/cuda-11.5
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
export PATH=${CUDA_HOME}/bin:${PATH}
export TORCH_CUDA_ARCH_LIST="3.5;5.0+PTX;6.0;7.0;7.5;8.0;8.6"
;;
cu113)
export CUDA_HOME=/usr/local/cuda-11.3
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
export PATH=${CUDA_HOME}/bin:${PATH}
export TORCH_CUDA_ARCH_LIST="3.5;5.0+PTX;6.0;7.0;7.5;8.0;8.6"
;;
cu102)
export CUDA_HOME=/usr/local/cuda-10.2
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
export PATH=${CUDA_HOME}/bin:${PATH}
export TORCH_CUDA_ARCH_LIST="3.5;5.0+PTX;6.0;7.0;7.5"
;;
*)
;;
esac
64 changes: 64 additions & 0 deletions .github/workflows/cuda/Linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash

# Took from https://github.com/pyg-team/pyg-lib/

OS=ubuntu2004

case ${1} in
cu118)
CUDA=11.8
APT_KEY=${OS}-${CUDA/./-}-local
FILENAME=cuda-repo-${APT_KEY}_${CUDA}.0-520.61.05-1_amd64.deb
URL=https://developer.download.nvidia.com/compute/cuda/${CUDA}.0/local_installers
;;
cu117)
CUDA=11.7
APT_KEY=${OS}-${CUDA/./-}-local
FILENAME=cuda-repo-${APT_KEY}_${CUDA}.1-515.65.01-1_amd64.deb
URL=https://developer.download.nvidia.com/compute/cuda/${CUDA}.1/local_installers
;;
cu116)
CUDA=11.6
APT_KEY=${OS}-${CUDA/./-}-local
FILENAME=cuda-repo-${APT_KEY}_${CUDA}.2-510.47.03-1_amd64.deb
URL=https://developer.download.nvidia.com/compute/cuda/${CUDA}.2/local_installers
;;
cu115)
CUDA=11.5
APT_KEY=${OS}-${CUDA/./-}-local
FILENAME=cuda-repo-${APT_KEY}_${CUDA}.2-495.29.05-1_amd64.deb
URL=https://developer.download.nvidia.com/compute/cuda/${CUDA}.2/local_installers
;;
cu113)
CUDA=11.3
APT_KEY=${OS}-${CUDA/./-}-local
FILENAME=cuda-repo-${APT_KEY}_${CUDA}.0-465.19.01-1_amd64.deb
URL=https://developer.download.nvidia.com/compute/cuda/${CUDA}.0/local_installers
;;
cu102)
CUDA=10.2
APT_KEY=${CUDA/./-}-local-${CUDA}.89-440.33.01
FILENAME=cuda-repo-${OS}-${APT_KEY}_1.0-1_amd64.deb
URL=https://developer.download.nvidia.com/compute/cuda/${CUDA}/Prod/local_installers
;;
*)
echo "Unrecognized CUDA_VERSION=${1}"
exit 1
;;
esac

wget -nv https://developer.download.nvidia.com/compute/cuda/repos/${OS}/x86_64/cuda-${OS}.pin
sudo mv cuda-${OS}.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget -nv ${URL}/${FILENAME}
sudo dpkg -i ${FILENAME}

if [ "${1}" = "cu117" ] || [ "${1}" = "cu118" ]; then
sudo cp /var/cuda-repo-${APT_KEY}/cuda-*-keyring.gpg /usr/share/keyrings/
else
sudo apt-key add /var/cuda-repo-${APT_KEY}/7fa2af80.pub
fi

sudo apt-get update
sudo apt-get -y install cuda

rm -f ${FILENAME}
Loading

0 comments on commit 76b1a44

Please sign in to comment.