Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
Torchaudio
Commits
51401084
Commit
51401084
authored
Jul 24, 2019
by
Edward Z. Yang
Committed by
jamarshon
Jul 24, 2019
Browse files
Put packaging scripts from 0.2.0 branch to master. (#161)
Signed-off-by:
Edward Z. Yang
<
ezyang@fb.com
>
parent
289f08af
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
328 additions
and
0 deletions
+328
-0
build_tools/packaging/README.md
build_tools/packaging/README.md
+102
-0
build_tools/packaging/conda/build_audio.sh
build_tools/packaging/conda/build_audio.sh
+48
-0
build_tools/packaging/conda/torchaudio/meta.yaml
build_tools/packaging/conda/torchaudio/meta.yaml
+53
-0
build_tools/packaging/wheel/build_from_source.sh
build_tools/packaging/wheel/build_from_source.sh
+34
-0
build_tools/packaging/wheel/linux_manywheel.sh
build_tools/packaging/wheel/linux_manywheel.sh
+41
-0
build_tools/packaging/wheel/osx_wheel.sh
build_tools/packaging/wheel/osx_wheel.sh
+50
-0
No files found.
build_tools/packaging/README.md
0 → 100644
View file @
51401084
# Building torchaudio packages for release
## Anaconda packages
### Linux
```
bash
nvidia-docker run
-it
--ipc
=
host
--rm
-v
$(
pwd
)
:/remote soumith/conda-cuda bash
pushd
remote/conda
conda config
--add
channels pytorch
conda config
--add
channels conda-forge
./build_audio.sh
```
To
install
bz2,
```
bash
cd
/opt/conda/conda-bld/linux-64/
# install dependencies
conda
install
pytorch-cpu
=
1.1.0
conda
install
sox
# install torchaudio
conda
install
/opt/conda/conda-bld/linux-64/torchaudio-cpu-0.2.0-py27_1.tar.bz2
```
To upload bz2,
```
bash
anaconda upload
-u
pytorch /opt/conda/conda-bld/linux-64/torchaudio
*
.bz2
```
### OSX
```
bash
# create a fresh anaconda environment / install and activate it
cd packaging/conda
conda install -y conda-build anaconda-client
conda config --add channels pytorch
conda config --add channels conda-forge
./build_audio.sh
```
To install bz2,
```
bash
cd /Users/jamarshon/anaconda3/conda-bld/osx-64/
# activate conda env (e.g
conda info --envs
conda activate /Users/jamarshon/minconda_wheel_env_tmp/envs/env2.7
# install dependencies
conda install pytorch-cpu=1.1.0
conda install sox
# install torchaudio
# and then try installing (e.g
conda install /Users/jamarshon/anaconda3/conda-bld/osx-64/torchaudio-0.2.0-py27_1.tar.bz2
```
To upload bz2,
```
bash
anaconda upload -u pytorch /Users/jamarshon/anaconda3/conda-bld/osx-64/torchaudio
*
.bz2
```
## Wheels
### Linux
```bash
nvidia-docker run -it --ipc=host --rm -v $(pwd):/remote soumith/manylinux-cuda90:latest bash
cd remote/wheel
./linux_manywheel.sh cpu
```
To install wheels,
```
bash
cd
../cpu
/opt/python/cp35-cp35m/bin/pip
install
torchaudio-0.2-cp35-cp35m-linux_x86_64.whl
```
To upload wheels,
```
bash
cd
../cpu
/opt/python/cp35-cp35m/bin/pip
install
twine
/opt/python/cp35-cp35m/bin/twine upload
*
.whl
```
### OSX
```
bash
pushd
wheel
./osx_wheel.sh
```
To install wheels,
```
bash
cd
~/torchaudio_wheels
conda activate /Users/jamarshon/minconda_wheel_env_tmp/envs/env2.7
pip
install
torchaudio-0.2-cp27-cp27m-macosx_10_6_x86_64.whl
```
To upload wheels,
```
bash
pip
install
twine
cd
~/torchaudio_wheels
twine upload
*
.whl
```
build_tools/packaging/conda/build_audio.sh
0 → 100755
View file @
51401084
#!/usr/bin/env bash
if
[[
-x
"/remote/anaconda_token"
]]
;
then
.
/remote/anaconda_token
||
true
fi
set
-ex
# Function to retry functions that sometimes timeout or have flaky failures
retry
()
{
$*
||
(
sleep
1
&&
$*
)
||
(
sleep
2
&&
$*
)
||
(
sleep
4
&&
$*
)
||
(
sleep
8
&&
$*
)
}
export
TORCHAUDIO_BUILD_VERSION
=
"0.2.0"
export
TORCHAUDIO_BUILD_NUMBER
=
1
SOURCE_DIR
=
"
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
"
>
/dev/null
&&
pwd
)
"
audio_rootdir
=
"
$(
pwd
)
/torchaudio-src"
if
[[
!
-d
"
$audio_rootdir
"
]]
;
then
rm
-rf
"
$audio_rootdir
"
git clone
"https://github.com/pytorch/audio"
"
$audio_rootdir
"
pushd
"
$audio_rootdir
"
git checkout v
$TORCHAUDIO_BUILD_VERSION
popd
fi
cd
"
$SOURCE_DIR
"
ANACONDA_USER
=
pytorch
conda config
--set
anaconda_upload no
# "$desired_cuda" == 'cpu'
export
TORCHAUDIO_PACKAGE_SUFFIX
=
""
export
CONDA_CUDATOOLKIT_CONSTRAINT
=
""
export
CUDA_VERSION
=
"None"
if
[[
"
$OSTYPE
"
!=
"darwin"
*
]]
;
then
export
TORCHAUDIO_PACKAGE_SUFFIX
=
"-cpu"
else
export
MACOSX_DEPLOYMENT_TARGET
=
10.9
CC
=
clang
CXX
=
clang++
fi
time
conda build
-c
$ANACONDA_USER
--no-anaconda-upload
--python
2.7 torchaudio
time
conda build
-c
$ANACONDA_USER
--no-anaconda-upload
--python
3.5 torchaudio
time
conda build
-c
$ANACONDA_USER
--no-anaconda-upload
--python
3.6 torchaudio
time
conda build
-c
$ANACONDA_USER
--no-anaconda-upload
--python
3.7 torchaudio
set
+e
build_tools/packaging/conda/torchaudio/meta.yaml
0 → 100644
View file @
51401084
package
:
name
:
torchaudio{{ environ.get('TORCHAUDIO_PACKAGE_SUFFIX') }}
version
:
"
{{
environ.get('TORCHAUDIO_BUILD_VERSION')
}}"
source
:
git_rev
:
v{{ environ.get('TORCHAUDIO_BUILD_VERSION') }}
git_url
:
https://github.com/pytorch/audio.git
requirements
:
build
:
-
{{
compiler('c')
}}
# [win]
-
{{
compiler('cxx')
}}
# [win]
host
:
-
python
-
setuptools
-
pytorch{{ environ.get('TORCHAUDIO_PACKAGE_SUFFIX') }} >=1.1.0
-
sox
run
:
-
python
-
pytorch{{ environ.get('TORCHAUDIO_PACKAGE_SUFFIX') }} >=1.1.0
-
librosa >=0.4.3
-
scipy
-
sox
build
:
number
:
{{
environ.get('TORCHAUDIO_BUILD_NUMBER')
}}
string
:
py{{py}}_{{environ.get('TORCHAUDIO_BUILD_NUMBER')}}
script
:
IS_CONDA=1 python setup.py install --single-version-externally-managed --record=record.txt
# [not win]
test
:
imports
:
-
torchaudio
-
torchaudio.datasets
-
torchaudio.kaldi_io
-
torchaudio.legacy
-
torchaudio.sox_effects
-
torchaudio.transforms
source_files
:
-
test
requires
:
-
pytest
-
librosa >=0.4.3
-
scipy
about
:
home
:
https://github.com/pytorch/audio
license
:
BSD
license_file
:
LICENSE
summary
:
'
simple
audio
I/O
for
pytorch'
build_tools/packaging/wheel/build_from_source.sh
0 → 100755
View file @
51401084
rm
-rf
source_code
mkdir
source_code
cd
source_code
wget
-q
-O
sox-14.4.2.tar.bz2
"http://downloads.sourceforge.net/project/sox/sox/14.4.2/sox-14.4.2.tar.bz2?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fsox%2Ffiles%2Fsox%2F14.4.2%2F&ts=1416316415&use_mirror=heanet"
wget
-q
-O
lame-3.99.5.tar.gz
"http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Flame%2Ffiles%2Flame%2F3.99%2F&ts=1416316457&use_mirror=kent"
wget
-q
-O
flac-1.3.2.tar.xz
"https://superb-dca2.dl.sourceforge.net/project/flac/flac-src/flac-1.3.2.tar.xz"
# unpack the dependencies
tar
xfp sox-14.4.2.tar.bz2
tar
xfp lame-3.99.5.tar.gz
tar
xfp flac-1.3.2.tar.xz
# build lame, statically
pushd
lame-3.99.5
./configure
--disable-shared
--enable-static
--prefix
=
"
$PREFIX
/audio/third_party/lame"
CFLAGS
=
-fPIC
CXXFLAGS
=
-fPIC
--with-pic
--disable-debug
--disable-dependency-tracking
--enable-nasm
make
-s
&&
make
install
popd
# build flac, statically
pushd
flac-1.3.2
./configure
--disable-shared
--enable-static
--prefix
=
"
$PREFIX
/audio/third_party/flac"
CFLAGS
=
-fPIC
CXXFLAGS
=
-fPIC
\
--with-pic
--disable-debug
--disable-dependency-tracking
make
-s
&&
make
install
popd
# build sox, statically
pushd
sox-14.4.2
./configure
--disable-shared
--enable-static
--prefix
=
"
$PREFIX
/audio/third_party/sox"
\
LDFLAGS
=
"-L
$PREFIX
/audio/third_party/lame/lib -L
$PREFIX
/audio/third_party/flac/lib"
\
CPPFLAGS
=
"-I
$PREFIX
/audio/third_party/lame/include -I
$PREFIX
/audio/third_party/flac/include"
\
--with-lame
--with-flac
--without-oggvorbis
--without-oss
--without-sndfile
CFLAGS
=
-fPIC
CXXFLAGS
=
-fPIC
--with-pic
--disable-debug
--disable-dependency-tracking
make
-s
&&
make
install
popd
build_tools/packaging/wheel/linux_manywheel.sh
0 → 100755
View file @
51401084
if
[
"$#"
-ne
1
]
;
then
echo
"Illegal number of parameters. Pass cuda version"
echo
"CUDA version should be cu90, cu100 or cpu"
exit
1
fi
export
CUVER
=
"
$1
"
# cu90 cu100 cpu
export
TORCHAUDIO_BUILD_VERSION
=
"0.2.0"
export
TORCHAUDIO_BUILD_NUMBER
=
"1"
export
OUT_DIR
=
"/remote/
$CUVER
"
cd
/opt/python
DESIRED_PYTHON
=(
*
/
)
for
desired_py
in
"
${
DESIRED_PYTHON
[@]
}
"
;
do
python_installations+
=(
"/opt/python/
$desired_py
"
)
done
OLD_PATH
=
$PATH
cd
/tmp
rm
-rf
audio
git clone https://github.com/pytorch/audio
-b
v
${
TORCHAUDIO_BUILD_VERSION
}
mkdir
audio/third_party
export
PREFIX
=
"/tmp"
.
/remote/wheel/build_from_source.sh
cd
/tmp/audio
for
PYDIR
in
"
${
python_installations
[@]
}
"
;
do
# wheels for numba does not work with python 2.7
if
[[
"
$PYDIR
"
==
"/opt/python/cp27-cp27m/"
||
"
$PYDIR
"
==
"/opt/python/cp27-cp27mu/"
]]
;
then
continue
;
fi
export
PATH
=
$PYDIR
/bin:
$OLD_PATH
pip
install
--upgrade
pip
pip
install
-r
requirements.txt
IS_WHEEL
=
1 python setup.py clean
IS_WHEEL
=
1 python setup.py bdist_wheel
mkdir
-p
$OUT_DIR
cp
dist/
*
.whl
$OUT_DIR
/
done
build_tools/packaging/wheel/osx_wheel.sh
0 → 100755
View file @
51401084
if
[[
":
$PATH
:"
==
*
"conda"
*
]]
;
then
echo
"existing anaconda install in PATH, remove it and run script"
exit
1
fi
# download and activate anaconda
rm
-rf
~/minconda_wheel_env_tmp
wget
-q
https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
&&
\
chmod
+x Miniconda3-latest-MacOSX-x86_64.sh
&&
\
./Miniconda3-latest-MacOSX-x86_64.sh
-b
-p
~/minconda_wheel_env_tmp
&&
\
rm
Miniconda3-latest-MacOSX-x86_64.sh
.
~/minconda_wheel_env_tmp/bin/activate
export
TORCHAUDIO_BUILD_VERSION
=
"0.2.0"
export
TORCHAUDIO_BUILD_NUMBER
=
"1"
export
OUT_DIR
=
~/torchaudio_wheels
export
MACOSX_DEPLOYMENT_TARGET
=
10.9
CC
=
clang
CXX
=
clang++
# TODO remove when pytorch is good https://github.com/pytorch/pytorch/issues/20030
brew
install
libomp
CURR_PATH
=
$(
pwd
)
cd
/tmp
rm
-rf
audio
git clone https://github.com/pytorch/audio
-b
v
${
TORCHAUDIO_BUILD_VERSION
}
mkdir
audio/third_party
export
PREFIX
=
"/tmp"
.
$CURR_PATH
/build_from_source.sh
cd
/tmp/audio
desired_pythons
=(
"2.7"
"3.5"
"3.6"
"3.7"
)
# for each python
for
desired_python
in
"
${
desired_pythons
[@]
}
"
do
# create and activate python env
env_name
=
"env
$desired_python
"
conda create
-yn
$env_name
python
=
"
$desired_python
"
conda activate
$env_name
# install torchaudio dependencies
pip
install
-r
requirements.txt
IS_WHEEL
=
1 python setup.py clean
IS_WHEEL
=
1 python setup.py bdist_wheel
mkdir
-p
$OUT_DIR
cp
dist/
*
.whl
$OUT_DIR
/
done
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment