Skip to content

Commit

Permalink
Enable python3 builds
Browse files Browse the repository at this point in the history
Reviewed By: rbgirshick

Differential Revision: D9691247

fbshipit-source-id: 7a9c1a33698be6907dede589965f8f4f4d337f93
  • Loading branch information
ashwinb authored and facebook-github-bot committed Oct 1, 2018
1 parent 4dc5e92 commit cbb0236
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 28 deletions.
10 changes: 5 additions & 5 deletions GETTING_STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

```
python2 tools/infer_simple.py \
python tools/infer_simple.py \
--cfg configs/12_2017_baselines/e2e_mask_rcnn_R-101-FPN_2x.yaml \
--output-dir /tmp/detectron-visualizations \
--image-ext jpg \
Expand All @@ -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).

```
python2 tools/test_net.py \
python tools/test_net.py \
--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 \
NUM_GPUS 1
Expand All @@ -44,7 +44,7 @@ python2 tools/test_net.py \
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 \
--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 \
Expand All @@ -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

```
python2 tools/train_net.py \
python tools/train_net.py \
--cfg configs/getting_started/tutorial_1gpu_e2e_faster_rcnn_R-50-FPN.yaml \
OUTPUT_DIR /tmp/detectron-output
```
Expand All @@ -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:

```
python2 tools/train_net.py \
python tools/train_net.py \
--multi-gpu-testing \
--cfg configs/getting_started/tutorial_2gpu_e2e_faster_rcnn_R-50-FPN.yaml \
OUTPUT_DIR /tmp/detectron-output
Expand Down
16 changes: 8 additions & 8 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ Please ensure that your Caffe2 installation was successful before proceeding by

```
# 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
# 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).
Expand All @@ -43,7 +43,7 @@ cd $COCOAPI/PythonAPI
make install
# Alternatively, if you do not have permissions or prefer
# 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.
Expand Down Expand Up @@ -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)):

```
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
Expand Down Expand Up @@ -101,7 +101,7 @@ cd $DETECTRON && make ops
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
Expand All @@ -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)):

```
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
Expand Down Expand Up @@ -200,8 +200,8 @@ library and include dir by using:
```
cmake .. \
# insert your Caffe2 CMake flags here
-DPYTHON_LIBRARY=$(python2 -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_LIBRARY=$(python -c "from distutils import sysconfig; print(sysconfig.get_python_lib())") \
-DPYTHON_INCLUDE_DIR=$(python -c "from distutils import sysconfig; print(sysconfig.get_python_inc())")
```

### Caffe2 with NNPACK Build
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# 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
default: dev

.PHONY: install
install:
python2 setup.py install
python setup.py install

.PHONY: ops
ops:
mkdir -p build && cd build && cmake .. && make -j$(shell nproc)

.PHONY: dev
dev:
python2 setup.py develop $(DEV_USER_FLAG)
python setup.py develop $(DEV_USER_FLAG)

.PHONY: clean
clean:
python2 setup.py develop --uninstall $(DEV_USER_FLAG)
python setup.py develop --uninstall $(DEV_USER_FLAG)
rm -rf build
2 changes: 1 addition & 1 deletion detectron/utils/training_stats.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python

# Copyright (c) 2017-present, Facebook, Inc.
#
Expand Down
2 changes: 1 addition & 1 deletion tools/convert_pkl_to_pb.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python

# Copyright (c) 2017-present, Facebook, Inc.
#
Expand Down
2 changes: 1 addition & 1 deletion tools/convert_selective_search.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python

# Copyright (c) 2017-present, Facebook, Inc.
#
Expand Down
2 changes: 1 addition & 1 deletion tools/generate_testdev_from_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python

# Copyright (c) 2017-present, Facebook, Inc.
#
Expand Down
2 changes: 1 addition & 1 deletion tools/infer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python

# Copyright (c) 2017-present, Facebook, Inc.
#
Expand Down
2 changes: 1 addition & 1 deletion tools/infer_simple.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python

# Copyright (c) 2017-present, Facebook, Inc.
#
Expand Down
2 changes: 1 addition & 1 deletion tools/pickle_caffe_blobs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python

# Copyright (c) 2017-present, Facebook, Inc.
#
Expand Down
2 changes: 1 addition & 1 deletion tools/reval.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python

# Copyright (c) 2017-present, Facebook, Inc.
#
Expand Down
2 changes: 1 addition & 1 deletion tools/test_net.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python

# Copyright (c) 2017-present, Facebook, Inc.
#
Expand Down
2 changes: 1 addition & 1 deletion tools/train_net.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python

# Copyright (c) 2017-present, Facebook, Inc.
#
Expand Down
2 changes: 1 addition & 1 deletion tools/visualize_results.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python

# Copyright (c) 2017-present, Facebook, Inc.
#
Expand Down

0 comments on commit cbb0236

Please sign in to comment.