Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't run on platform without cuda #20

Open
liuheng135 opened this issue Mar 13, 2023 · 2 comments
Open

can't run on platform without cuda #20

liuheng135 opened this issue Mar 13, 2023 · 2 comments

Comments

@liuheng135
Copy link

i try to run xrloc on a platform without cuda, but it does not work!

below is the error:
[03/13/2023 17:42:56 INFO] ==================================================
[03/13/2023 17:42:56 INFO] ****************** Init Success ******************
[03/13/2023 17:42:56 INFO] ==================================================
[03/13/2023 17:42:56 INFO] ======================[1 / 3]======================
[03/13/2023 17:42:56 INFO] Image path: query/000001.jpg
[03/13/2023 17:43:03 INFO] Local feature number: 2443
[03/13/2023 17:43:04 INFO] Coarse location number: 1
[03/13/2023 17:43:06 INFO] 3d points size: 7540
Traceback (most recent call last):
File "run_benchmark.py", line 52, in
main(args.query_path, args.map_path, args.json)
File "run_benchmark.py", line 34, in main
ret = loc.refine_localize(image, camera, ref_image_ids)
File "/home/gavin/Develop/xrlocalization/xrloc/localizer.py", line 212, in refine_localize
feat, image_ids)
File "/home/gavin/Develop/xrlocalization/xrloc/localizer.py", line 168, in establish_correspondences_2d3d
feat['shape'][0])
File "/home/gavin/Develop/xrlocalization/xrloc/localizer.py", line 113, in feature_match_2d3d
pred = self.matcher.match(query_feat, train_feat)
File "/home/gavin/Develop/xrlocalization/xrloc/matchers/matcher.py", line 57, in match
output = self.matcher(data)
File "/home/gavin/Develop/xrlocalization/xrloc/matchers/gam.py", line 34, in call
self.config['dis_thres'])
File "/home/gavin/Develop/xrlocalization/xrloc/matchers/gam.py", line 104, in knn_ratio_match
mask = torch.ones((dists.shape[0], k), dtype=torch.bool).cuda()
File "/home/gavin/miniconda3/envs/xrloc/lib/python3.7/site-packages/torch/cuda/init.py", line 221, in _lazy_init
raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabled

@liuheng135
Copy link
Author

I found a temporary solution to this issue:

index fd9081f..252f89c 100644
--- a/xrloc/matchers/bmnet.py
+++ b/xrloc/matchers/bmnet.py
@@ -63,8 +63,8 @@ class ConcatenationLayer(torch.nn.Module):
     def forward(self, in0, in1, matches):
         num_matches = matches.shape[1]
         num_channels0, num_channels1 = in0.shape[1], in1.shape[1]
-        edges_feature_0 = torch.zeros(1, num_channels0, num_matches).cuda()
-        edges_feature_1 = torch.zeros(1, num_channels1, num_matches).cuda()
+        edges_feature_0 = torch.zeros(1, num_channels0, num_matches)
+        edges_feature_1 = torch.zeros(1, num_channels1, num_matches)
         edges_feature_0[0] = torch.index_select(in0[0],
                                                 dim=1,
                                                 index=matches[0])
@@ -86,7 +86,7 @@ class HungarianPooling(torch.autograd.Function):
         htb = torch.zeros([rows, cols], dtype=torch.int64)
         htb[row_ind, col_ind] = 1
         assignments = htb[edges[0], edges[1]]
-        assignments = assignments.cuda()
+        assignments = assignments
         ctx.save_for_backward(assignments)
         return assignments
 
diff --git a/xrloc/matchers/gam.py b/xrloc/matchers/gam.py
index 094f814..b9e1b62 100644
--- a/xrloc/matchers/gam.py
+++ b/xrloc/matchers/gam.py
@@ -101,7 +101,7 @@ class GAM(object):
         dists = torch.sqrt(2 * (1 - sims.clamp(-1, 1)))
 
         # Filter by ratio and thres
-        mask = torch.ones((dists.shape[0], k), dtype=torch.bool).cuda()
+        mask = torch.ones((dists.shape[0], k), dtype=torch.bool)
         mask[:, 0] = (dists[:, 0] < 1)
         for i in range(1, k):
             mask[:,
@@ -111,7 +111,7 @@ class GAM(object):
 
         # Compose match
         inds0 = torch.arange(0, inds1.shape[0]).unsqueeze(1).expand(
-            [inds1.shape[0], k]).cuda()
+            [inds1.shape[0], k])
         inds0, inds1 = inds0.reshape(-1), inds1.reshape(-1)
         matches = torch.stack([inds0, inds1],
                               dim=1).to(torch.long).permute([1, 0])'

@HailinYu0414
Copy link
Member

Currently, only such a temporary solution can be used first, we will fix this issue later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants