From e800c3609e64b4297c9713d209d1527c7841f627 Mon Sep 17 00:00:00 2001 From: Ethan Rublee Date: Sun, 30 Sep 2018 15:04:42 -0700 Subject: [PATCH] Dev env using baremetal conda. --- .gitignore | 1 + README.rst | 30 ++++++++++++++++++++++++++---- dev_env.sh | 41 ----------------------------------------- path.bash.inc | 15 +++++++++++++++ setup_dev_env.sh | 29 +++++++++++++++++++++++++++++ 5 files changed, 71 insertions(+), 45 deletions(-) delete mode 100755 dev_env.sh create mode 100644 path.bash.inc create mode 100755 setup_dev_env.sh diff --git a/.gitignore b/.gitignore index ca834e14f0..73330e5a94 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ torchgeometry.egg-info/ .eggs/* .cache/* .pytest_cache/* +.dev_env \ No newline at end of file diff --git a/README.rst b/README.rst index a323651abc..4d3c12f75d 100644 --- a/README.rst +++ b/README.rst @@ -1,4 +1,3 @@ - .. image:: https://github.com/arraiy/torchgeometry/blob/master/docs/source/_static/img/torchgeometry_logo.svg :width: 350 px :align: center @@ -31,7 +30,7 @@ Quick Usage x_deg = dgm.rad2deg(x_rad) torch.allclose(x_rad, dgm.deg2rad(x_deg)) # True - + ------------------------------------------------------- .. code:: python @@ -44,8 +43,31 @@ Quick Usage warper = dgm.HomographyWarper(32, 32) img_ref_to_dst = warper(img_ref, dst_homo_ref) # NxCxHxW - - + + +Development Setup +================= + +Assuming that you are on ubuntu 16.04, with nvidia-drivers installed. + +In bash, source the ``path.bash.inc`` script. This will install a +local conda environment under ``./.dev_env``, which includes pytorch +and some dependencies (no root required). + +.. code:: bash + + source ./path.bash.inc + python -c "import torchgeometry; print(torchgeometry.__version__)" + + + +To install, or update the conda environment run ``setup_dev_env.sh`` + +.. code:: bash + + ./setup_dev_env.sh + + Installation ============ diff --git a/dev_env.sh b/dev_env.sh deleted file mode 100755 index ed1e5eefae..0000000000 --- a/dev_env.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -ex -# The purpose of this script is simplify running scripts inside of our -# dev_env docker container. It mounts the workspace and the -# workspace/../build directory inside of the container, and executes -# any arguments passed to the dev_env.sh -script_link="$( readlink "$BASH_SOURCE" )" || script_link="$BASH_SOURCE" -apparent_sdk_dir="${script_link%/*}" -if [ "$apparent_sdk_dir" == "$script_link" ]; then - apparent_sdk_dir=. -fi -sdk_dir="$( command cd -P "$apparent_sdk_dir" > /dev/null && pwd -P )" - -bash_args=$@ -if [[ -z "$bash_args" ]] ; then - bash_args=bash -fi - -docker_data_volume="-v ${DATA_DIR}:${DATA_DIR}" -if [[ -z "$DATA_DIR" ]] ; then - docker_data_volume="-v $(pwd):$(pwd)" -fi - -docker_command=docker - -repo=${ARRAIY_REPO:=arraiy/torchgeometry} - -$docker_command \ - run \ - -it \ - $docker_data_volume \ - -v $sdk_dir:/code/torchgeometry \ - -v $HOME/.Xauthority:/root/.Xauthority \ - --net=host \ - --env="DISPLAY" \ - --env="QT_X11_NO_MITSHM=1" \ - --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ - --privileged \ - --device /dev/dri \ - $repo \ - bash -c "cd /code/torchgeometry && $bash_args" - diff --git a/path.bash.inc b/path.bash.inc new file mode 100644 index 0000000000..0fd650d0cb --- /dev/null +++ b/path.bash.inc @@ -0,0 +1,15 @@ +# The purpose of this script is simplify running scripts inside of our +# dev_env docker container. It mounts the workspace and the +# workspace/../build directory inside of the container, and executes +# any arguments passed to the dev_env.sh +script_link="$( readlink "$BASH_SOURCE" )" || script_link="$BASH_SOURCE" +apparent_sdk_dir="${script_link%/*}" +if [ "$apparent_sdk_dir" == "$script_link" ]; then + apparent_sdk_dir=. +fi +sdk_dir="$( command cd -P "$apparent_sdk_dir" > /dev/null && pwd -P )" +if [ ! -e $sdk_dir/.dev_env/bin/conda ]; then + $sdk_dir/setup_dev_env.sh +fi +source $sdk_dir/.dev_env/bin/activate $sdk_dir/.dev_env +export PYTHONPATH=$PYTHONPATH:$sdk_root diff --git a/setup_dev_env.sh b/setup_dev_env.sh new file mode 100755 index 0000000000..fb0b1b0d80 --- /dev/null +++ b/setup_dev_env.sh @@ -0,0 +1,29 @@ +#!/bin/bash -ex +script_link="$( readlink "$BASH_SOURCE" )" || script_link="$BASH_SOURCE" +apparent_sdk_dir="${script_link%/*}" +if [ "$apparent_sdk_dir" == "$script_link" ]; then + apparent_sdk_dir=. +fi +sdk_dir="$( command cd -P "$apparent_sdk_dir" > /dev/null && pwd -P )" + +mkdir -p $sdk_dir/.dev_env + +if [ ! -e $sdk_dir/.dev_env/miniconda.sh ]; then + curl -o $sdk_dir/.dev_env/miniconda.sh \ + -O https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh + chmod +x $sdk_dir/.dev_env/miniconda.sh +fi +if [ ! -e $sdk_dir/.dev_env/bin/conda ]; then + $sdk_dir/.dev_env/miniconda.sh -b -u -p $sdk_dir/.dev_env +fi + +$sdk_dir/.dev_env/bin/conda install -y \ + ipython \ + numpy \ + pytorch \ + torchvision \ + opencv \ + -c pytorch + +$sdk_dir/.dev_env/bin/conda clean -ya +