Skip to content

Commit 7ab0cf2

Browse files
aclegg3Skylion007
andauthored
Fix ci pytorch cuda (#1946)
* (bugfix): fix python-lint CI * Try to improve python lint * try pytorch suggested previous version 1.12 w/ cuda 11.3 Co-authored-by: Aaron Gokaslan <aaronGokaslan@gmail.com>
1 parent 59456b9 commit 7ab0cf2

11 files changed

Lines changed: 89 additions & 99 deletions

File tree

.circleci/config.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ commands:
123123
. activate habitat
124124
# For whatever reason we have to install pytorch first. If it isn't
125125
# it installs the 1.4 cpuonly version. Which is no good.
126-
conda install -q -y pytorch torchvision cudatoolkit=11.3 -c pytorch
126+
#conda install -q -y pytorch=1.12 torchvision pytorch-cuda=11.3 -c pytorch -c nvidia
127+
conda install pytorch==1.12.1 torchvision==0.13.1 cudatoolkit=11.3 -c pytorch
127128
conda install -q -y -c conda-forge ninja numpy pytest pytest-cov ccache hypothesis pytest-mock
128129
pip install pytest-sugar pytest-xdist pytest-benchmark opencv-python cython mock
129130
fi
@@ -184,13 +185,6 @@ jobs:
184185
- run:
185186
name: setup
186187
command: |
187-
# Updated llvm to v 10
188-
sudo apt-get update
189-
sudo apt-get install llvm-10
190-
cd /usr/bin
191-
sudo rm llvm-config
192-
sudo ln -s llvm-config-10 llvm-config
193-
cd ~/project/
194188
pip install -U pip
195189
pip install -U --prefer-binary \
196190
black \

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ repos:
6868
exclude: docs/
6969

7070
- repo: https://github.com/pycqa/flake8
71-
rev: 4.0.1
71+
rev: 5.0.4
7272
hooks:
7373
- id: flake8
7474
exclude: docs/
7575
additional_dependencies: &flake8_dependencies
7676
- flake8-bugbear==22.1.11
7777
- flake8-builtins==1.5.3
7878
- flake8-comprehensions==3.10.0
79-
- flake8-return==1.1.3
79+
- flake8-return==1.2.0
8080
- flake8-simplify==0.17.0
8181

8282
- repo: https://github.com/asottile/yesqa

examples/fairmotion_interface.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def save_metadata(self, file: str):
221221
break
222222

223223
# we are no longer overwriting a file
224-
elif "/" not in file:
224+
if "/" not in file:
225225
# file is not a file path, we need to aim it at our directory
226226
if ".json" not in file:
227227
# add file type
@@ -422,14 +422,14 @@ def convert_CMUamass_single_pose(
422422
raise KeyError(
423423
"Error: pose data does not have a transform for that joint name"
424424
)
425-
elif joint_type not in [phy.JointType.Spherical]:
425+
if joint_type not in [phy.JointType.Spherical]:
426426
raise NotImplementedError(
427427
f"Error: {joint_type} is not a supported joint type"
428428
)
429-
else:
430-
T = pose.get_transform(pose_joint_index, local=True)
431-
if joint_type == phy.JointType.Spherical:
432-
Q, _ = conversions.T2Qp(T)
429+
430+
T = pose.get_transform(pose_joint_index, local=True)
431+
if joint_type == phy.JointType.Spherical:
432+
Q, _ = conversions.T2Qp(T)
433433

434434
new_pose += list(Q)
435435

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ ignore =
2727
A003,
2828
C401,C402,C408,
2929
SIM105,SIM113,SIM9
30-
R504,
30+
R504,R505,
3131
W503
3232
per-file-ignores =
3333
*/__init__.py:F401

src_python/habitat_sim/nav/greedy_geodesic_follower.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,7 @@ def next_action_along(self, goal_pos: np.ndarray) -> Any:
163163

164164
if next_act == GreedyFollowerCodes.ERROR:
165165
raise errors.GreedyFollowerError()
166-
else:
167-
return self.action_mapping[next_act]
166+
return self.action_mapping[next_act]
168167

169168
def find_path(self, goal_pos: np.ndarray) -> List[Any]:
170169
r"""Finds the sequence actions that greedily follow the geodesic

src_python/habitat_sim/registry.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ def _wrapper(controller: Type[SceneNodeControl]):
7575

7676
if controller is None:
7777
return _wrapper
78-
else:
79-
return _wrapper(controller)
78+
79+
return _wrapper(controller)
8080

8181
@classmethod
8282
def register_noise_model(
@@ -104,8 +104,8 @@ def _wrapper(noise_model: Type[SensorNoiseModel]):
104104

105105
if noise_model is None:
106106
return _wrapper
107-
else:
108-
return _wrapper(noise_model)
107+
108+
return _wrapper(noise_model)
109109

110110
@classmethod
111111
def register_pose_extractor(
@@ -133,8 +133,8 @@ def _wrapper(pose_extractor: Type[PoseExtractor]):
133133

134134
if pose_extractor is None:
135135
return _wrapper
136-
else:
137-
return _wrapper(pose_extractor)
136+
137+
return _wrapper(pose_extractor)
138138

139139
@classmethod
140140
def _get_impl(cls, _type, name: str):

src_python/habitat_sim/sensors/noise_models/no_noise_model.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def apply(
3232
) -> Union[ndarray, "torch.Tensor"]:
3333
if isinstance(x, np.ndarray):
3434
return x.copy()
35-
elif torch is not None and torch.is_tensor(x):
35+
if torch is not None and torch.is_tensor(x):
3636
return x.clone()
37-
else:
38-
return x
37+
return x

src_python/habitat_sim/sensors/noise_models/redwood_depth_noise_model.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def _undistort(x, y, z, model):
4040

4141
if f < 1e-5:
4242
return 0.0
43-
else:
44-
return z / f
43+
44+
return z / f
4545

4646

4747
@numba.jit(nopython=True, parallel=True, fastmath=True)
@@ -134,13 +134,12 @@ def simulate(self, gt_depth: Union[ndarray, "Tensor"]) -> Union[ndarray, "Tensor
134134
if cuda_enabled:
135135
if isinstance(gt_depth, np.ndarray):
136136
return self._impl.simulate_from_cpu(gt_depth)
137-
else:
138-
noisy_depth = torch.empty_like(gt_depth)
139-
rows, cols = gt_depth.size()
140-
self._impl.simulate_from_gpu(
141-
gt_depth.data_ptr(), rows, cols, noisy_depth.data_ptr() # type: ignore[attr-defined]
142-
)
143-
return noisy_depth
137+
noisy_depth = torch.empty_like(gt_depth)
138+
rows, cols = gt_depth.size()
139+
self._impl.simulate_from_gpu(
140+
gt_depth.data_ptr(), rows, cols, noisy_depth.data_ptr() # type: ignore[attr-defined]
141+
)
142+
return noisy_depth
144143
else:
145144
return self._impl.simulate(gt_depth)
146145

src_python/habitat_sim/simulator.py

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -649,76 +649,76 @@ def draw_observation(self) -> None:
649649
# do nothing in draw observation, get_observation will be called after this
650650
# run the simulation there
651651
return
652-
else:
653-
assert self._sim.renderer is not None
654-
# see if the sensor is attached to a scene graph, otherwise it is invalid,
655-
# and cannot make any observation
656-
if not self._sensor_object.object:
657-
raise habitat_sim.errors.InvalidAttachedObject(
658-
"Sensor observation requested but sensor is invalid.\
652+
653+
assert self._sim.renderer is not None
654+
# see if the sensor is attached to a scene graph, otherwise it is invalid,
655+
# and cannot make any observation
656+
if not self._sensor_object.object:
657+
raise habitat_sim.errors.InvalidAttachedObject(
658+
"Sensor observation requested but sensor is invalid.\
659659
(has it been detached from a scene node?)"
660-
)
661-
self._sim.renderer.draw(self._sensor_object, self._sim)
660+
)
661+
self._sim.renderer.draw(self._sensor_object, self._sim)
662662

663663
def _draw_observation_async(self) -> None:
664664
if self._spec.sensor_type == SensorType.AUDIO:
665665
# do nothing in draw observation, get_observation will be called after this
666666
# run the simulation there
667667
return
668-
else:
669-
assert self._sim.renderer is not None
670-
if (
671-
self._spec.sensor_type == SensorType.SEMANTIC
672-
and self._sim.get_active_scene_graph()
673-
is not self._sim.get_active_semantic_scene_graph()
674-
):
675-
raise RuntimeError(
676-
"Async drawing doesn't support semantic rendering when there are multiple scene graphs"
677-
)
678-
# TODO: sync this path with renderer changes as above (render from sensor object)
679668

680-
# see if the sensor is attached to a scene graph, otherwise it is invalid,
681-
# and cannot make any observation
682-
if not self._sensor_object.object:
683-
raise habitat_sim.errors.InvalidAttachedObject(
684-
"Sensor observation requested but sensor is invalid.\
685-
(has it been detached from a scene node?)"
686-
)
669+
assert self._sim.renderer is not None
670+
if (
671+
self._spec.sensor_type == SensorType.SEMANTIC
672+
and self._sim.get_active_scene_graph()
673+
is not self._sim.get_active_semantic_scene_graph()
674+
):
675+
raise RuntimeError(
676+
"Async drawing doesn't support semantic rendering when there are multiple scene graphs"
677+
)
678+
# TODO: sync this path with renderer changes as above (render from sensor object)
679+
680+
# see if the sensor is attached to a scene graph, otherwise it is invalid,
681+
# and cannot make any observation
682+
if not self._sensor_object.object:
683+
raise habitat_sim.errors.InvalidAttachedObject(
684+
"Sensor observation requested but sensor is invalid.\
685+
(has it been detached from a scene node?)"
686+
)
687687

688-
# get the correct scene graph based on application
689-
if self._spec.sensor_type == SensorType.SEMANTIC:
690-
if self._sim.semantic_scene is None:
691-
raise RuntimeError(
692-
"SemanticSensor observation requested but no SemanticScene is loaded"
693-
)
694-
scene = self._sim.get_active_semantic_scene_graph()
695-
else: # SensorType is DEPTH or any other type
696-
scene = self._sim.get_active_scene_graph()
688+
# get the correct scene graph based on application
689+
if self._spec.sensor_type == SensorType.SEMANTIC:
690+
if self._sim.semantic_scene is None:
691+
raise RuntimeError(
692+
"SemanticSensor observation requested but no SemanticScene is loaded"
693+
)
694+
scene = self._sim.get_active_semantic_scene_graph()
695+
else: # SensorType is DEPTH or any other type
696+
scene = self._sim.get_active_scene_graph()
697697

698-
# now, connect the agent to the root node of the current scene graph
698+
# now, connect the agent to the root node of the current scene graph
699699

700-
# sanity check is not needed on agent:
701-
# because if a sensor is attached to a scene graph,
702-
# it implies the agent is attached to the same scene graph
703-
# (it assumes backend simulator will guarantee it.)
700+
# sanity check is not needed on agent:
701+
# because if a sensor is attached to a scene graph,
702+
# it implies the agent is attached to the same scene graph
703+
# (it assumes backend simulator will guarantee it.)
704704

705-
agent_node = self._agent.scene_node
706-
agent_node.parent = scene.get_root_node()
705+
agent_node = self._agent.scene_node
706+
agent_node.parent = scene.get_root_node()
707707

708-
# get the correct scene graph based on application
709-
if self._spec.sensor_type == SensorType.SEMANTIC:
710-
scene = self._sim.get_active_semantic_scene_graph()
711-
else: # SensorType is DEPTH or any other type
712-
scene = self._sim.get_active_scene_graph()
708+
# get the correct scene graph based on application
709+
if self._spec.sensor_type == SensorType.SEMANTIC:
710+
scene = self._sim.get_active_semantic_scene_graph()
711+
else: # SensorType is DEPTH or any other type
712+
scene = self._sim.get_active_scene_graph()
713713

714-
render_flags = habitat_sim.gfx.Camera.Flags.NONE
714+
render_flags = habitat_sim.gfx.Camera.Flags.NONE
715715

716-
if self._sim.frustum_culling:
717-
render_flags |= habitat_sim.gfx.Camera.Flags.FRUSTUM_CULLING
716+
if self._sim.frustum_culling:
717+
render_flags |= habitat_sim.gfx.Camera.Flags.FRUSTUM_CULLING
718718

719-
self._sim.renderer.enqueue_async_draw_job(
720-
self._sensor_object, scene, self.view, render_flags
721-
)
719+
self._sim.renderer.enqueue_async_draw_job(
720+
self._sensor_object, scene, self.view, render_flags
721+
)
722722

723723
def get_observation(self) -> Union[ndarray, "Tensor"]:
724724
if self._spec.sensor_type == SensorType.AUDIO:

src_python/habitat_sim/utils/data/data_structures.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ def __init__(self, capacity=1000):
1414
def __getitem__(self, key):
1515
if not self.__contains__(key):
1616
raise KeyError("Key {} not in extractor cache".format(key))
17-
else:
18-
# Accessing the data should move it to front of cache
19-
k, data = self._order.pop(key)
20-
self._order[key] = (k, data)
21-
return data
17+
18+
# Accessing the data should move it to front of cache
19+
k, data = self._order.pop(key)
20+
self._order[key] = (k, data)
21+
return data
2222

2323
def __contains__(self, key):
2424
return key in self._order

0 commit comments

Comments
 (0)