mirror of
				https://github.com/facebookresearch/sam2.git
				synced 2025-11-04 11:32:12 +08:00 
			
		
		
		
	Update INSTALL.md (#156)
This PR suggests a way to resolve the error of `unsupported Microsoft Visual Studio version!` in INSTALL.md. Adding `-allow-unsupported-compiler` argument for the `nvcc` worked. Editing [setup.py](https://github.com/facebookresearch/segment-anything-2/blob/main/setup.py) is required to add the `-allow-unsupported-compiler` argument for `nvcc`. ```python def get_extensions(): srcs = ["sam2/csrc/connected_components.cu"] compile_args = { "cxx": [], "nvcc": [ "-DCUDA_HAS_FP16=1", "-D__CUDA_NO_HALF_OPERATORS__", "-D__CUDA_NO_HALF_CONVERSIONS__", "-D__CUDA_NO_HALF2_OPERATORS__", "-allow-unsupported-compiler" # Add this argument ], } ext_modules = [CUDAExtension("sam2._C", srcs, extra_compile_args=compile_args)] return ext_modules ```
This commit is contained in:
		
							parent
							
								
									6f7e700c37
								
							
						
					
					
						commit
						0bac418736
					
				
							
								
								
									
										30
									
								
								INSTALL.md
									
									
									
									
									
								
							
							
						
						
									
										30
									
								
								INSTALL.md
									
									
									
									
									
								
							@ -111,3 +111,33 @@ OLD_GPU, USE_FLASH_ATTN, MATH_KERNEL_ON = True, True, True
 | 
				
			|||||||
```
 | 
					```
 | 
				
			||||||
to relax the attention kernel setting and use other kernels than Flash Attention.
 | 
					to relax the attention kernel setting and use other kernels than Flash Attention.
 | 
				
			||||||
</details>
 | 
					</details>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<details>
 | 
				
			||||||
 | 
					<summary>
 | 
				
			||||||
 | 
					I got `Error compiling objects for extension`
 | 
				
			||||||
 | 
					</summary>
 | 
				
			||||||
 | 
					<br/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					You may see error log of:
 | 
				
			||||||
 | 
					> unsupported Microsoft Visual Studio version! Only the versions between 2017 and 2022 (inclusive) are supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					This is probably because your versions of CUDA and Visual Studio are incompatible. (see also https://stackoverflow.com/questions/78515942/cuda-compatibility-with-visual-studio-2022-version-17-10 for a discussion in stackoverflow).<br> 
 | 
				
			||||||
 | 
					You may be able to fix this by adding the `-allow-unsupported-compiler` argument to `nvcc` after L48 in the [setup.py](https://github.com/facebookresearch/segment-anything-2/blob/main/setup.py). <br>
 | 
				
			||||||
 | 
					After adding the argument, `get_extension()` will look like this:
 | 
				
			||||||
 | 
					```python
 | 
				
			||||||
 | 
					def get_extensions():
 | 
				
			||||||
 | 
					    srcs = ["sam2/csrc/connected_components.cu"]
 | 
				
			||||||
 | 
					    compile_args = {
 | 
				
			||||||
 | 
					        "cxx": [],
 | 
				
			||||||
 | 
					        "nvcc": [
 | 
				
			||||||
 | 
					            "-DCUDA_HAS_FP16=1",
 | 
				
			||||||
 | 
					            "-D__CUDA_NO_HALF_OPERATORS__",
 | 
				
			||||||
 | 
					            "-D__CUDA_NO_HALF_CONVERSIONS__",
 | 
				
			||||||
 | 
					            "-D__CUDA_NO_HALF2_OPERATORS__",
 | 
				
			||||||
 | 
					            "-allow-unsupported-compiler"  # Add this argument
 | 
				
			||||||
 | 
					        ],
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    ext_modules = [CUDAExtension("sam2._C", srcs, extra_compile_args=compile_args)]
 | 
				
			||||||
 | 
					    return ext_modules
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					</details>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user