Skip to content

Commit e1c2251

Browse files
author
Saurav Agarwal
committed
update setup to torch 2.5.1
1 parent 7e111a7 commit e1c2251

File tree

8 files changed

+102
-67
lines changed

8 files changed

+102
-67
lines changed

.github/workflows/cd.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
with:
4141
fetch-depth: 0
4242

43-
- uses: pypa/cibuildwheel@v2.17
43+
- uses: pypa/cibuildwheel@v2.21
4444

4545
- name: Upload wheels
4646
uses: actions/upload-artifact@v4
@@ -81,26 +81,40 @@ jobs:
8181
- name: 'CI docker base'
8282
uses: ./.github/docker-base-action
8383
with:
84-
base_tag: pytorch2.2.2-cuda12.2.2-ros2humble
84+
base_tag: jammy-torch2.5.1-cuda12.4.1
8585
github_token: ${{ secrets.GITHUB_TOKEN }}
8686
- name: cleanup
8787
run: docker system prune -a -f
8888
- name: 'CI docker base'
8989
uses: ./.github/docker-base-action
9090
with:
91-
base_tag: pytorch2.2.2-ros2humble
91+
base_tag: jammy-torch2.5.1-humble
9292
github_token: ${{ secrets.GITHUB_TOKEN }}
9393
- name: cleanup
9494
run: docker system prune -a -f
9595
- name: 'CI docker base'
9696
uses: ./.github/docker-base-action
9797
with:
98-
base_tag: pytorch2.2.2-cuda12.2.2
98+
base_tag: jammy-torch2.5.1-cuda12.4.1-humble
9999
github_token: ${{ secrets.GITHUB_TOKEN }}
100100
- name: cleanup
101101
run: docker system prune -a -f
102102
- name: 'CI docker base'
103103
uses: ./.github/docker-base-action
104104
with:
105-
base_tag: pytorch2.2.2
105+
base_tag: jammy-torch2.5.1
106+
github_token: ${{ secrets.GITHUB_TOKEN }}
107+
- name: cleanup
108+
run: docker system prune -a -f
109+
- name: 'CI docker base'
110+
uses: ./.github/docker-base-action
111+
with:
112+
base_tag: noble-torch2.5.1-jazzy
113+
github_token: ${{ secrets.GITHUB_TOKEN }}
114+
- name: cleanup
115+
run: docker system prune -a -f
116+
- name: 'CI docker base'
117+
uses: ./.github/docker-base-action
118+
with:
119+
base_tag: noble-torch2.5.1
106120
github_token: ${{ secrets.GITHUB_TOKEN }}

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ dependencies = ["numpy", "pyyaml",
3030
]
3131

3232
[project.optional-dependencies]
33-
nn = ["torch >=2.1", "torchvision >=2.1", "torch_geometric >=2.1"]
33+
nn = ["torch >=2.5", "torchvision>=0.20", "torch_geometric >=2.6"]
3434
core_test = ["pytest >=6"]
35-
test = ["pytest >=6", "torch >=2.1", "torchvision"]
35+
test = ["pytest >=6", "torch >=2.5", "torchvision"]
3636

3737
[project.urls]
3838
Homepage = "https://github.com/KumarRobotics/CoverageControl"
@@ -41,7 +41,7 @@ Discussions = "https://github.com/KumarRobotics/CoverageControl/discussions"
4141
Changelog = "https://github.com/KumarRobotics/CoverageControl/releases"
4242

4343
[tool.scikit-build]
44-
minimum-version = "0.8"
44+
minimum-version = "0.10"
4545
# cmake.version = ">=3.28"
4646
metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
4747
sdist.cmake = true

python/coverage_control/coverage_env_utils.py

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import torch
3535
import torch_geometric
3636
import torchvision
37-
from scipy.spatial import distance_matrix
3837

3938
from .core import CoverageSystem, DblVector, DblVectorVector, Parameters, PointVector
4039

@@ -335,33 +334,6 @@ def get_weights(env: CoverageSystem, params: Parameters) -> torch.Tensor:
335334

336335
return edge_weights
337336

338-
# Legacy edge weights used in previous research
339-
# The weights are proportional to the distance
340-
# Trying to move away from this
341-
@staticmethod
342-
def robot_positions_to_edge_weights(
343-
robot_positions: PointVector, world_map_size: int, comm_range: float
344-
) -> torch.Tensor:
345-
"""
346-
Convert robot positions to edge weights
347-
348-
Args:
349-
robot_positions: robot positions
350-
world_map_size: size of the world map
351-
comm_range: communication range
352-
353-
Returns:
354-
torch.Tensor: edge weights
355-
"""
356-
x = numpy.array(robot_positions)
357-
s_mat = distance_matrix(x, x)
358-
s_mat[s_mat > comm_range] = 0
359-
c_mat = (world_map_size**2) / (s_mat.shape[0] ** 2)
360-
c_mat = 3 / c_mat
361-
graph_obs = c_mat * s_mat
362-
363-
return graph_obs
364-
365337
@staticmethod
366338
def get_torch_geometric_data(
367339
env: CoverageSystem,
@@ -431,3 +403,32 @@ def get_torch_geometric_data(
431403
# maps[r_idx][3] = heatmap_y
432404

433405
# return maps
406+
407+
408+
# Legacy edge weights used in previous research
409+
# The weights are proportional to the distance
410+
# Trying to move away from this
411+
# @staticmethod
412+
# def robot_positions_to_edge_weights(
413+
# robot_positions: PointVector, world_map_size: int, comm_range: float
414+
# ) -> torch.Tensor:
415+
# """
416+
# Convert robot positions to edge weights
417+
418+
# Args:
419+
# robot_positions: robot positions
420+
# world_map_size: size of the world map
421+
# comm_range: communication range
422+
423+
# Returns:
424+
# torch.Tensor: edge weights
425+
# """
426+
# x = numpy.array(robot_positions)
427+
# s_mat = distance_matrix(x, x)
428+
# s_mat[s_mat > comm_range] = 0
429+
# c_mat = (world_map_size**2) / (s_mat.shape[0] ** 2)
430+
# c_mat = 3 / c_mat
431+
# graph_obs = c_mat * s_mat
432+
433+
# return graph_obs
434+

python/tests/test_coverage_env_utils.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ def test_get_raw_local_maps():
9292
)
9393
assert local_maps.dtype == torch.float32
9494
saved_local_maps = torch.load(
95-
os.path.join(script_dir, "data/coverage_env_utils/local_maps.pt")
95+
os.path.join(script_dir, "data/coverage_env_utils/local_maps.pt"),
96+
weights_only=True
9697
)
9798
is_all_close = torch.allclose(local_maps, saved_local_maps)
9899
assert is_all_close
@@ -112,7 +113,8 @@ def test_get_raw_obstacle_maps():
112113
)
113114
assert obstacle_maps.dtype == torch.float32
114115
saved_obstacle_maps = torch.load(
115-
os.path.join(script_dir, "data/coverage_env_utils/obstacle_maps.pt")
116+
os.path.join(script_dir, "data/coverage_env_utils/obstacle_maps.pt"),
117+
weights_only=True
116118
)
117119
is_all_close = torch.allclose(obstacle_maps, saved_obstacle_maps)
118120
assert is_all_close
@@ -128,7 +130,8 @@ def test_get_communication_maps():
128130
assert comm_maps.shape == (params.pNumRobots, 2, 32, 32)
129131
assert comm_maps.dtype == torch.float32
130132
saved_comm_maps = torch.load(
131-
os.path.join(script_dir, "data/coverage_env_utils/comm_maps.pt")
133+
os.path.join(script_dir, "data/coverage_env_utils/comm_maps.pt"),
134+
weights_only=True
132135
)
133136
is_all_close = torch.allclose(comm_maps, saved_comm_maps)
134137
max_error = torch.max(torch.abs(comm_maps - saved_comm_maps))
@@ -147,7 +150,8 @@ def test_resize_maps():
147150
assert resized_local_maps.shape == (params.pNumRobots, 32, 32)
148151
assert resized_local_maps.dtype == torch.float32
149152
saved_resized_local_maps = torch.load(
150-
os.path.join(script_dir, "data/coverage_env_utils/resized_local_maps.pt")
153+
os.path.join(script_dir, "data/coverage_env_utils/resized_local_maps.pt"),
154+
weights_only=True
151155
)
152156
is_all_close = torch.allclose(resized_local_maps, saved_resized_local_maps)
153157
assert is_all_close
@@ -162,7 +166,7 @@ def test_get_maps():
162166
assert isinstance(maps, torch.Tensor)
163167
assert maps.shape == (params.pNumRobots, 4, 32, 32)
164168
assert maps.dtype == torch.float32
165-
saved_maps = torch.load(os.path.join(script_dir, "data/coverage_env_utils/maps.pt"))
169+
saved_maps = torch.load(os.path.join(script_dir, "data/coverage_env_utils/maps.pt"), weights_only=True)
166170
is_all_close = torch.allclose(maps, saved_maps)
167171
assert is_all_close
168172
is_all_equal = torch.equal(maps, saved_maps)
@@ -178,7 +182,8 @@ def test_get_voronoi_features():
178182
assert voronoi_features.shape == (params.pNumRobots, feature_len)
179183
assert voronoi_features.dtype == torch.float32
180184
saved_voronoi_features = torch.load(
181-
os.path.join(script_dir, "data/coverage_env_utils/voronoi_features.pt")
185+
os.path.join(script_dir, "data/coverage_env_utils/voronoi_features.pt"),
186+
weights_only=True
182187
)
183188
is_all_close = torch.allclose(voronoi_features, saved_voronoi_features)
184189
assert is_all_close
@@ -194,7 +199,8 @@ def test_get_robot_positions():
194199
assert robot_positions.shape == (params.pNumRobots, 2)
195200
assert robot_positions.dtype == torch.float32
196201
saved_robot_positions = torch.load(
197-
os.path.join(script_dir, "data/coverage_env_utils/robot_positions.pt")
202+
os.path.join(script_dir, "data/coverage_env_utils/robot_positions.pt"),
203+
weights_only=True
198204
)
199205
is_all_close = torch.allclose(robot_positions, saved_robot_positions)
200206
assert is_all_close
@@ -210,7 +216,8 @@ def test_get_weights():
210216
assert weights.shape == (params.pNumRobots, params.pNumRobots)
211217
assert weights.dtype == torch.float32
212218
saved_weights = torch.load(
213-
os.path.join(script_dir, "data/coverage_env_utils/weights.pt")
219+
os.path.join(script_dir, "data/coverage_env_utils/weights.pt"),
220+
weights_only=True
214221
)
215222
is_all_close = torch.allclose(weights, saved_weights)
216223
assert is_all_close
@@ -229,9 +236,10 @@ def test_get_torch_geometric_data():
229236
assert data.x.dtype == torch.float32
230237
assert data.edge_index.shape == (2, 16)
231238
assert data.edge_index.dtype == torch.long
232-
saved_data = torch.load(
233-
os.path.join(script_dir, "data/coverage_env_utils/torch_geometric_data.pt")
234-
)
239+
saved_data = torch_geometric.data.data.Data.from_dict(torch.load(
240+
os.path.join(script_dir, "data/coverage_env_utils/torch_geometric_data.pt"),
241+
weights_only=True
242+
))
235243
is_all_close = torch.allclose(data.x, saved_data.x)
236244
assert is_all_close
237245
is_all_equal = torch.equal(data.x, saved_data.x)

python/tests/test_models.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,30 @@
3333

3434
with torch.no_grad():
3535
model_file = os.path.join(
36-
script_dir, "data/lpac/models/model_k3_1024_state_dict.pt"
37-
)
36+
script_dir, "data/lpac/models/model_k3_1024_state_dict.pt"
37+
)
3838
learning_config_file = os.path.join(
39-
script_dir, "data/params/learning_params.toml"
40-
)
39+
script_dir, "data/params/learning_params.toml"
40+
)
4141
learning_config = IOUtils.load_toml(learning_config_file)
4242
lpac_model = cc_nn.LPAC(learning_config).to(device)
43-
lpac_model.load_state_dict(torch.load(model_file))
43+
lpac_model.load_state_dict(torch.load(model_file, weights_only=True))
4444

4545
lpac_model.eval()
4646

4747
use_comm_maps = learning_config["ModelConfig"]["UseCommMaps"]
4848
map_size = learning_config["CNNBackBone"]["ImageSize"]
4949

50-
lpac_inputs = torch.load(os.path.join(script_dir, "data/lpac/lpac_inputs.pt"))
50+
lpac_inputs_dict = torch.load(os.path.join(script_dir, "data/lpac/lpac_inputs.pt"), weights_only=True)
51+
lpac_inputs = [torch_geometric.data.Data.from_dict(d) for d in lpac_inputs_dict]
5152

5253

5354
def test_cnn():
5455
with torch.no_grad():
55-
ref_cnn_outputs = torch.load(os.path.join(script_dir, "data/lpac/cnn_outputs.pt"))
56+
ref_cnn_outputs = torch.load(
57+
os.path.join(script_dir, "data/lpac/cnn_outputs.pt"),
58+
weights_only=True
59+
)
5660
cnn_model = lpac_model.cnn_backbone.to(device).eval()
5761

5862
for i in range(0, len(lpac_inputs)):
@@ -76,8 +80,9 @@ def test_cnn():
7680
def test_lpac():
7781
with torch.no_grad():
7882
ref_lpac_outputs = torch.load(
79-
os.path.join(script_dir, "data/lpac/lpac_outputs.pt")
80-
)
83+
os.path.join(script_dir, "data/lpac/lpac_outputs.pt"),
84+
weights_only=True
85+
)
8186

8287
for i in range(0, len(lpac_inputs)):
8388
lpac_output = lpac_model(lpac_inputs[i])

setup_utils/docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ARG BASE_IMAGE=ghcr.io/kumarrobotics/pytorch_base
2-
ARG BASE_TAG=pytorch2.2.2
2+
ARG BASE_TAG=latest
33
ARG SETUP_ARGS="--with-cuda"
44

55
FROM ${BASE_IMAGE}:${BASE_TAG}

setup_utils/install_dependencies.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,15 +277,15 @@ InstallBoost () {
277277
fi
278278
}
279279

280-
BOOST_VERSION=1.85.0
280+
BOOST_VERSION=1.86.0
281281
BOOST_TAR_NAME=$(echo boost_${BOOST_VERSION} | tr . _)
282282
GMP_VERSION=6.3.0
283283
GMP_TAR_NAME=$(echo gmp-${GMP_VERSION})
284284
MPFR_VERSION=4.2.1
285285
MPFR_TAR_NAME=$(echo mpfr-${MPFR_VERSION})
286286
EIGEN_VERSION=3.4.0
287287
EIGEN_TAR_NAME=$(echo eigen-${EIGEN_VERSION})
288-
CGAL_VERSION=5.6.1
288+
CGAL_VERSION=6.0.1
289289
CGAL_TAR_NAME=$(echo CGAL-${CGAL_VERSION})
290290

291291
if [ -n "$BOOST" ]; then

setup_utils/manylinux_2_28_before-all.sh

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,23 @@
33
yum install -y epel-release
44
yum install -y wget yum-utils python3-devel
55

6-
yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo
7-
yum install --setopt=obsoletes=0 -y \
8-
cuda-nvcc-12-1-12.1.105-1 \
9-
cuda-cudart-devel-12-1-12.1.105-1 \
10-
libcurand-devel-12-1-10.3.2.106-1 \
11-
libcudnn8-devel-8.9.3.28-1.cuda12.1 \
12-
libcublas-devel-12-1-12.1.3.1-1 \
13-
libnccl-devel-2.18.3-1+cuda12.1
6+
dnf config-manger --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo
7+
dnf -y install --setopt=obsoletes=0 \
8+
cuda-compiler-12-4-12.4.1-1 \
9+
cuda-libraries-12-4-12.4.1-1 \
10+
cuda-libraries-devel-12-4-12.4.1-1 \
11+
cuda-nvcc-12-4-12.4.131-1 \
12+
cuda-cudart-devel-12-4-12.4.127-1 \
13+
libcurand-devel-12-4-10.3.5.147-1 \
14+
libcudnn9-devel-cuda-12-9.5.1.17-1 \
15+
libcublas-devel-12-4-12.4.5.8-1 \
16+
libnccl-devel-2.23.4-1+cuda12.4
1417

1518
export PATH=/usr/local/cuda/bin:$PATH
1619
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
20+
export CUDA_HOME=/usr/local/cuda
21+
export CUDA_ROOT=/usr/local/cuda
22+
export CUDA_PATH=/usr/local/cuda
23+
export CUDADIR=/usr/local/cuda
1724

1825
bash setup_utils/install_dependencies.sh --boost --gmp --mpfr --eigen --cgal

0 commit comments

Comments
 (0)