Commit cbb0236d authored by Ashwin Bharambe's avatar Ashwin Bharambe Committed by Facebook Github Bot

Enable python3 builds

Reviewed By: rbgirshick

Differential Revision: D9691247

fbshipit-source-id: 7a9c1a33698be6907dede589965f8f4f4d337f93
parent 4dc5e92e
...@@ -11,7 +11,7 @@ This document provides brief tutorials covering Detectron for inference and trai ...@@ -11,7 +11,7 @@ This document provides brief tutorials covering Detectron for inference and trai
To run inference on a directory of image files (`demo/*.jpg` in this example), you can use the `infer_simple.py` tool. In this example, we're using an end-to-end trained Mask R-CNN model with a ResNet-101-FPN backbone from the model zoo: To run inference on a directory of image files (`demo/*.jpg` in this example), you can use the `infer_simple.py` tool. In this example, we're using an end-to-end trained Mask R-CNN model with a ResNet-101-FPN backbone from the model zoo:
``` ```
python2 tools/infer_simple.py \ python tools/infer_simple.py \
--cfg configs/12_2017_baselines/e2e_mask_rcnn_R-101-FPN_2x.yaml \ --cfg configs/12_2017_baselines/e2e_mask_rcnn_R-101-FPN_2x.yaml \
--output-dir /tmp/detectron-visualizations \ --output-dir /tmp/detectron-visualizations \
--image-ext jpg \ --image-ext jpg \
...@@ -35,7 +35,7 @@ Detectron should automatically download the model from the URL specified by the ...@@ -35,7 +35,7 @@ Detectron should automatically download the model from the URL specified by the
This example shows how to run an end-to-end trained Mask R-CNN model from the model zoo using a single GPU for inference. As configured, this will run inference on all images in `coco_2014_minival` (which must be properly installed). This example shows how to run an end-to-end trained Mask R-CNN model from the model zoo using a single GPU for inference. As configured, this will run inference on all images in `coco_2014_minival` (which must be properly installed).
``` ```
python2 tools/test_net.py \ python tools/test_net.py \
--cfg configs/12_2017_baselines/e2e_mask_rcnn_R-101-FPN_2x.yaml \ --cfg configs/12_2017_baselines/e2e_mask_rcnn_R-101-FPN_2x.yaml \
TEST.WEIGHTS https://s3-us-west-2.amazonaws.com/detectron/35861858/12_2017_baselines/e2e_mask_rcnn_R-101-FPN_2x.yaml.02_32_51.SgT4y1cO/output/train/coco_2014_train:coco_2014_valminusminival/generalized_rcnn/model_final.pkl \ TEST.WEIGHTS https://s3-us-west-2.amazonaws.com/detectron/35861858/12_2017_baselines/e2e_mask_rcnn_R-101-FPN_2x.yaml.02_32_51.SgT4y1cO/output/train/coco_2014_train:coco_2014_valminusminival/generalized_rcnn/model_final.pkl \
NUM_GPUS 1 NUM_GPUS 1
...@@ -44,7 +44,7 @@ python2 tools/test_net.py \ ...@@ -44,7 +44,7 @@ python2 tools/test_net.py \
Running inference with the same model using `$N` GPUs (e.g., `N=8`). Running inference with the same model using `$N` GPUs (e.g., `N=8`).
``` ```
python2 tools/test_net.py \ python tools/test_net.py \
--cfg configs/12_2017_baselines/e2e_mask_rcnn_R-101-FPN_2x.yaml \ --cfg configs/12_2017_baselines/e2e_mask_rcnn_R-101-FPN_2x.yaml \
--multi-gpu-testing \ --multi-gpu-testing \
TEST.WEIGHTS https://s3-us-west-2.amazonaws.com/detectron/35861858/12_2017_baselines/e2e_mask_rcnn_R-101-FPN_2x.yaml.02_32_51.SgT4y1cO/output/train/coco_2014_train:coco_2014_valminusminival/generalized_rcnn/model_final.pkl \ TEST.WEIGHTS https://s3-us-west-2.amazonaws.com/detectron/35861858/12_2017_baselines/e2e_mask_rcnn_R-101-FPN_2x.yaml.02_32_51.SgT4y1cO/output/train/coco_2014_train:coco_2014_valminusminival/generalized_rcnn/model_final.pkl \
...@@ -61,7 +61,7 @@ This is a tiny tutorial showing how to train a model on COCO. The model will be ...@@ -61,7 +61,7 @@ This is a tiny tutorial showing how to train a model on COCO. The model will be
#### 1. Training with 1 GPU #### 1. Training with 1 GPU
``` ```
python2 tools/train_net.py \ python tools/train_net.py \
--cfg configs/getting_started/tutorial_1gpu_e2e_faster_rcnn_R-50-FPN.yaml \ --cfg configs/getting_started/tutorial_1gpu_e2e_faster_rcnn_R-50-FPN.yaml \
OUTPUT_DIR /tmp/detectron-output OUTPUT_DIR /tmp/detectron-output
``` ```
...@@ -78,7 +78,7 @@ python2 tools/train_net.py \ ...@@ -78,7 +78,7 @@ python2 tools/train_net.py \
We've also provided configs to illustrate training with 2, 4, and 8 GPUs using learning schedules that will be approximately equivalent to the one used with 1 GPU above. The configs are located at: `configs/getting_started/tutorial_{2,4,8}gpu_e2e_faster_rcnn_R-50-FPN.yaml`. For example, launching a training job with 2 GPUs will look like this: We've also provided configs to illustrate training with 2, 4, and 8 GPUs using learning schedules that will be approximately equivalent to the one used with 1 GPU above. The configs are located at: `configs/getting_started/tutorial_{2,4,8}gpu_e2e_faster_rcnn_R-50-FPN.yaml`. For example, launching a training job with 2 GPUs will look like this:
``` ```
python2 tools/train_net.py \ python tools/train_net.py \
--multi-gpu-testing \ --multi-gpu-testing \
--cfg configs/getting_started/tutorial_2gpu_e2e_faster_rcnn_R-50-FPN.yaml \ --cfg configs/getting_started/tutorial_2gpu_e2e_faster_rcnn_R-50-FPN.yaml \
OUTPUT_DIR /tmp/detectron-output OUTPUT_DIR /tmp/detectron-output
......
...@@ -22,11 +22,11 @@ Please ensure that your Caffe2 installation was successful before proceeding by ...@@ -22,11 +22,11 @@ Please ensure that your Caffe2 installation was successful before proceeding by
``` ```
# To check if Caffe2 build was successful # To check if Caffe2 build was successful
python2 -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure" python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"
# To check if Caffe2 GPU build was successful # To check if Caffe2 GPU build was successful
# This must print a number > 0 in order to use Detectron # This must print a number > 0 in order to use Detectron
python2 -c 'from caffe2.python import workspace; print(workspace.NumCudaDevices())' python -c 'from caffe2.python import workspace; print(workspace.NumCudaDevices())'
``` ```
If the `caffe2` Python package is not found, you likely need to adjust your `PYTHONPATH` environment variable to include its location (`/path/to/caffe2/build`, where `build` is the Caffe2 CMake build directory). If the `caffe2` Python package is not found, you likely need to adjust your `PYTHONPATH` environment variable to include its location (`/path/to/caffe2/build`, where `build` is the Caffe2 CMake build directory).
...@@ -43,7 +43,7 @@ cd $COCOAPI/PythonAPI ...@@ -43,7 +43,7 @@ cd $COCOAPI/PythonAPI
make install make install
# Alternatively, if you do not have permissions or prefer # Alternatively, if you do not have permissions or prefer
# not to install the COCO API into global site-packages # not to install the COCO API into global site-packages
python2 setup.py install --user python setup.py install --user
``` ```
Note that instructions like `# COCOAPI=/path/to/install/cocoapi` indicate that you should pick a path where you'd like to have the software cloned and then set an environment variable (`COCOAPI` in this case) accordingly. Note that instructions like `# COCOAPI=/path/to/install/cocoapi` indicate that you should pick a path where you'd like to have the software cloned and then set an environment variable (`COCOAPI` in this case) accordingly.
...@@ -72,7 +72,7 @@ cd $DETECTRON && make ...@@ -72,7 +72,7 @@ cd $DETECTRON && make
Check that Detectron tests pass (e.g. for [`SpatialNarrowAsOp test`](detectron/tests/test_spatial_narrow_as_op.py)): Check that Detectron tests pass (e.g. for [`SpatialNarrowAsOp test`](detectron/tests/test_spatial_narrow_as_op.py)):
``` ```
python2 $DETECTRON/detectron/tests/test_spatial_narrow_as_op.py python $DETECTRON/detectron/tests/test_spatial_narrow_as_op.py
``` ```
## That's All You Need for Inference ## That's All You Need for Inference
...@@ -101,7 +101,7 @@ cd $DETECTRON && make ops ...@@ -101,7 +101,7 @@ cd $DETECTRON && make ops
Check that the custom operator tests pass: Check that the custom operator tests pass:
``` ```
python2 $DETECTRON/detectron/tests/test_zero_even_op.py python $DETECTRON/detectron/tests/test_zero_even_op.py
``` ```
## Docker Image ## Docker Image
...@@ -118,7 +118,7 @@ docker build -t detectron:c2-cuda9-cudnn7 . ...@@ -118,7 +118,7 @@ docker build -t detectron:c2-cuda9-cudnn7 .
Run the image (e.g. for [`BatchPermutationOp test`](detectron/tests/test_batch_permutation_op.py)): Run the image (e.g. for [`BatchPermutationOp test`](detectron/tests/test_batch_permutation_op.py)):
``` ```
nvidia-docker run --rm -it detectron:c2-cuda9-cudnn7 python2 detectron/tests/test_batch_permutation_op.py nvidia-docker run --rm -it detectron:c2-cuda9-cudnn7 python detectron/tests/test_batch_permutation_op.py
``` ```
## Troubleshooting ## Troubleshooting
...@@ -200,8 +200,8 @@ library and include dir by using: ...@@ -200,8 +200,8 @@ library and include dir by using:
``` ```
cmake .. \ cmake .. \
# insert your Caffe2 CMake flags here # insert your Caffe2 CMake flags here
-DPYTHON_LIBRARY=$(python2 -c "from distutils import sysconfig; print(sysconfig.get_python_lib())") \ -DPYTHON_LIBRARY=$(python -c "from distutils import sysconfig; print(sysconfig.get_python_lib())") \
-DPYTHON_INCLUDE_DIR=$(python2 -c "from distutils import sysconfig; print(sysconfig.get_python_inc())") -DPYTHON_INCLUDE_DIR=$(python -c "from distutils import sysconfig; print(sysconfig.get_python_inc())")
``` ```
### Caffe2 with NNPACK Build ### Caffe2 with NNPACK Build
......
# Don't use the --user flag for setup.py develop mode with virtualenv. # Don't use the --user flag for setup.py develop mode with virtualenv.
DEV_USER_FLAG=$(shell python2 -c "import sys; print('' if hasattr(sys, 'real_prefix') else '--user')") DEV_USER_FLAG=$(shell python -c "import sys; print('' if hasattr(sys, 'real_prefix') else '--user')")
.PHONY: default .PHONY: default
default: dev default: dev
.PHONY: install .PHONY: install
install: install:
python2 setup.py install python setup.py install
.PHONY: ops .PHONY: ops
ops: ops:
...@@ -14,9 +14,9 @@ ops: ...@@ -14,9 +14,9 @@ ops:
.PHONY: dev .PHONY: dev
dev: dev:
python2 setup.py develop $(DEV_USER_FLAG) python setup.py develop $(DEV_USER_FLAG)
.PHONY: clean .PHONY: clean
clean: clean:
python2 setup.py develop --uninstall $(DEV_USER_FLAG) python setup.py develop --uninstall $(DEV_USER_FLAG)
rm -rf build rm -rf build
#!/usr/bin/env python2 #!/usr/bin/env python
# Copyright (c) 2017-present, Facebook, Inc. # Copyright (c) 2017-present, Facebook, Inc.
# #
......
#!/usr/bin/env python2 #!/usr/bin/env python
# Copyright (c) 2017-present, Facebook, Inc. # Copyright (c) 2017-present, Facebook, Inc.
# #
......
#!/usr/bin/env python2 #!/usr/bin/env python
# Copyright (c) 2017-present, Facebook, Inc. # Copyright (c) 2017-present, Facebook, Inc.
# #
......
#!/usr/bin/env python2 #!/usr/bin/env python
# Copyright (c) 2017-present, Facebook, Inc. # Copyright (c) 2017-present, Facebook, Inc.
# #
......
#!/usr/bin/env python2 #!/usr/bin/env python
# Copyright (c) 2017-present, Facebook, Inc. # Copyright (c) 2017-present, Facebook, Inc.
# #
......
#!/usr/bin/env python2 #!/usr/bin/env python
# Copyright (c) 2017-present, Facebook, Inc. # Copyright (c) 2017-present, Facebook, Inc.
# #
......
#!/usr/bin/env python2 #!/usr/bin/env python
# Copyright (c) 2017-present, Facebook, Inc. # Copyright (c) 2017-present, Facebook, Inc.
# #
......
#!/usr/bin/env python2 #!/usr/bin/env python
# Copyright (c) 2017-present, Facebook, Inc. # Copyright (c) 2017-present, Facebook, Inc.
# #
......
#!/usr/bin/env python2 #!/usr/bin/env python
# Copyright (c) 2017-present, Facebook, Inc. # Copyright (c) 2017-present, Facebook, Inc.
# #
......
#!/usr/bin/env python2 #!/usr/bin/env python
# Copyright (c) 2017-present, Facebook, Inc. # Copyright (c) 2017-present, Facebook, Inc.
# #
......
#!/usr/bin/env python2 #!/usr/bin/env python
# Copyright (c) 2017-present, Facebook, Inc. # Copyright (c) 2017-present, Facebook, Inc.
# #
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment