Skip to content

Commit 3711628

Browse files
committed
Add support for latest PyTorch and setuptools
* Add `pyproject.toml` and `setup.cfg` for PEP 517/518 support * Add `weights_only=False` for `torch.load` (torch>=2.6) * Add missing dependencies in `requirements.txt` * Add `clean.sh` for cleaning up build artifacts * Update `INSTALL.md` for installation instructions
1 parent 8caccce commit 3711628

File tree

7 files changed

+72
-29
lines changed

7 files changed

+72
-29
lines changed

clean.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
rm -rf build/ pcdet.egg-info/ dist/ .eggs/ .setuptools-cfg .venv
4+
find . -type f -name "*.so" -exec rm -f {} \;
5+
find . -type d -name "__pycache__" -exec rm -rf {} \; -prune

docs/INSTALL.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
### Requirements
44
All the codes are tested in the following environment:
5-
* Linux (tested on Ubuntu 14.04/16.04/18.04/20.04/21.04)
5+
* Linux (tested on Ubuntu 14.04/16.04/18.04/20.04/21.04/24.04)
66
* Python 3.6+
7-
* PyTorch 1.1 or higher (tested on PyTorch 1.1, 1,3, 1,5~1.10)
7+
* PyTorch 1.1 or higher (tested on PyTorch 1.1, 1,3, 1,5~1.10, 2.8)
88
* CUDA 9.0 or higher (PyTorch 1.3+ needs CUDA 9.2+)
99
* [`spconv v1.0 (commit 8da6f96)`](https://github.com/traveller59/spconv/tree/8da6f967fb9a054d8870c3515b1b44eca2103634) or [`spconv v1.2`](https://github.com/traveller59/spconv) or [`spconv v2.x`](https://github.com/traveller59/spconv)
1010

1111

1212
### Install `pcdet v0.5`
13-
NOTE: Please re-install `pcdet v0.5` by running `python setup.py develop` even if you have already installed previous version.
13+
NOTE: Please re-install `pcdet v0.5` by running `pip install -e .` even if you have already installed previous version.
1414

1515
a. Clone this repository.
1616
```shell
@@ -34,5 +34,14 @@ b. Install the dependent libraries as follows:
3434

3535
c. Install this `pcdet` library and its dependent libraries by running the following command:
3636
```shell
37-
python setup.py develop
37+
pip install -e .
38+
```
39+
* To build the wheel only, run the following command:
40+
```shell
41+
pip install build
42+
python -m build --wheel
43+
```
44+
* To install the built wheel, run the following command:
45+
```shell
46+
pip install dist/*.whl
3847
```

pcdet/models/detectors/detector3d_template.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,10 @@ def load_params_from_file(self, filename, logger, to_cpu=False, pre_trained_path
364364

365365
logger.info('==> Loading parameters from checkpoint %s to %s' % (filename, 'CPU' if to_cpu else 'GPU'))
366366
loc_type = torch.device('cpu') if to_cpu else None
367-
checkpoint = torch.load(filename, map_location=loc_type)
367+
checkpoint = torch.load(filename, map_location=loc_type, weights_only=False)
368368
model_state_disk = checkpoint['model_state']
369369
if not pre_trained_path is None:
370-
pretrain_checkpoint = torch.load(pre_trained_path, map_location=loc_type)
370+
pretrain_checkpoint = torch.load(pre_trained_path, map_location=loc_type, weights_only=False)
371371
pretrain_model_state_disk = pretrain_checkpoint['model_state']
372372
model_state_disk.update(pretrain_model_state_disk)
373373

@@ -389,7 +389,7 @@ def load_params_with_optimizer(self, filename, to_cpu=False, optimizer=None, log
389389

390390
logger.info('==> Loading parameters from checkpoint %s to %s' % (filename, 'CPU' if to_cpu else 'GPU'))
391391
loc_type = torch.device('cpu') if to_cpu else None
392-
checkpoint = torch.load(filename, map_location=loc_type)
392+
checkpoint = torch.load(filename, map_location=loc_type, weights_only=False)
393393
epoch = checkpoint.get('epoch', -1)
394394
it = checkpoint.get('it', 0.0)
395395

@@ -405,7 +405,7 @@ def load_params_with_optimizer(self, filename, to_cpu=False, optimizer=None, log
405405
src_file, ext = filename[:-4], filename[-3:]
406406
optimizer_filename = '%s_optim.%s' % (src_file, ext)
407407
if os.path.exists(optimizer_filename):
408-
optimizer_ckpt = torch.load(optimizer_filename, map_location=loc_type)
408+
optimizer_ckpt = torch.load(optimizer_filename, map_location=loc_type, weights_only=False)
409409
optimizer.load_state_dict(optimizer_ckpt['optimizer_state'])
410410

411411
if 'version' in checkpoint:

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["setuptools >= 67.0", "wheel", "torch >= 2.0", "numpy >= 2.0"]
3+
build-backend = "setuptools.build_meta"

requirements.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@ tqdm
1010
torchvision
1111
SharedArray
1212
opencv-python
13-
pyquaternion
13+
pyquaternion
14+
kornia<0.7
15+
ninja
16+
av2

setup.cfg

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[metadata]
2+
name = pcdet
3+
description = OpenPCDet is a general codebase for 3D object detection from point cloud
4+
author = Shaoshuai Shi
5+
author_email = [email protected]
6+
license_expression = Apache-2.0
7+
url = https://github.com/open-mmlab/OpenPCDet
8+
classifiers =
9+
Programming Language :: Python :: 3
10+
Operating System :: OS Independent
11+
12+
[options]
13+
packages = find:
14+
python_requires = >=3.6
15+
install_requires =
16+
numpy
17+
llvmlite
18+
numba
19+
tensorboardX
20+
easydict
21+
pyyaml
22+
scikit-image
23+
tqdm
24+
SharedArray
25+
; spconv ; spconv has different names depending on the cuda version
26+
27+
[options.packages.find]
28+
exclude =
29+
tools
30+
data
31+
output
32+
33+
[options.extras_require]
34+
dev =
35+
pytest
36+
flake8
37+
mypy
38+
39+
[options.entry_points]
40+
console_scripts =
41+
pcdet-train = pcdet.tools.train:main
42+
pcdet-test = pcdet.tools.test:main

setup.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import subprocess
33

4-
from setuptools import find_packages, setup
4+
from setuptools import setup
55
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
66

77

@@ -32,26 +32,7 @@ def write_version_to_file(version, target_file):
3232
write_version_to_file(version, 'pcdet/version.py')
3333

3434
setup(
35-
name='pcdet',
3635
version=version,
37-
description='OpenPCDet is a general codebase for 3D object detection from point cloud',
38-
install_requires=[
39-
'numpy',
40-
'llvmlite',
41-
'numba',
42-
'tensorboardX',
43-
'easydict',
44-
'pyyaml',
45-
'scikit-image',
46-
'tqdm',
47-
'SharedArray',
48-
# 'spconv', # spconv has different names depending on the cuda version
49-
],
50-
51-
author='Shaoshuai Shi',
52-
author_email='[email protected]',
53-
license='Apache License 2.0',
54-
packages=find_packages(exclude=['tools', 'data', 'output']),
5536
cmdclass={
5637
'build_ext': BuildExtension,
5738
},

0 commit comments

Comments
 (0)