Performance optimizations and rendering improvements
GPU multi-processing fix: - gpu.py: revert to CUDA_VISIBLE_DEVICES approach with lazy CuPy init (Device.use() caused CUDA_ERROR_NO_BINARY_FOR_GPU on GPU 1) - CuPy is imported lazily on first to_gpu() call, allowing CUDA_VISIBLE_DEVICES to be set before CUDA context creation - nvidia-smi used for GPU count detection (no CUDA import needed) - pipeline.py: add tip message suggesting -w N when multiple GPUs detected Rendering improvements: - Title: split into bold title (14pt) + italic description (10pt) - North arrow: moved inside data area (top-right) with transparent background — no longer overlaps title - Colorbar: full height (compass gap removed), ScalarFormatter with useOffset=False to prevent scientific notation on small values Performance: - rendering.py: save matplotlib figure to BytesIO instead of temp PNG file — eliminates disk I/O between matplotlib and PIL - visualizations.py: cap max_dist at 300 for ray-tracing (SVF, openness, aniso_open) — avoids 500+ iterations at 0.2m resolution - pipeline.py: deduplicate n_gpus calculation in parallel path
This commit is contained in:
@ -480,7 +480,9 @@ def generate_svf(dem_file, basename, vis_dir, resolution, shared=None):
|
||||
angles = np.linspace(0, 2 * np.pi, n_dirs, endpoint=False)
|
||||
dx_dir = np.cos(angles)
|
||||
dy_dir = np.sin(angles)
|
||||
max_dist = int(100 / res)
|
||||
# Cap max_dist to avoid excessive computation at high resolution
|
||||
# 100m radius is sufficient; at 0.2m that's 500 steps which is very slow
|
||||
max_dist = min(int(100 / res), 300)
|
||||
|
||||
padded = xp.pad(dem, max_dist, mode='constant', constant_values=xp.nan)
|
||||
svf = xp.zeros_like(dem)
|
||||
@ -556,7 +558,7 @@ def generate_openness(dem_file, basename, vis_dir, resolution, positive=True, sh
|
||||
angles = np.linspace(0, 2 * np.pi, n_dirs, endpoint=False)
|
||||
dx_dir = np.cos(angles)
|
||||
dy_dir = np.sin(angles)
|
||||
max_dist = int(100 / res)
|
||||
max_dist = min(int(100 / res), 300)
|
||||
|
||||
padded = xp.pad(dem, max_dist, mode='constant', constant_values=xp.nan)
|
||||
openness_sum = xp.zeros_like(dem)
|
||||
@ -1320,7 +1322,7 @@ def generate_svf(dem_file, basename, vis_dir, resolution, shared=None):
|
||||
angles = np.linspace(0, 2 * np.pi, n_dirs, endpoint=False)
|
||||
dx_dir = np.cos(angles)
|
||||
dy_dir = np.sin(angles)
|
||||
max_dist = int(100 / res)
|
||||
max_dist = min(int(100 / res), 300)
|
||||
|
||||
padded = xp.pad(dem, max_dist, mode='constant', constant_values=xp.nan)
|
||||
svf_sum = xp.zeros_like(dem)
|
||||
@ -1405,7 +1407,7 @@ def generate_aniso_open(dem_file, basename, vis_dir, resolution, shared=None):
|
||||
# aligned with Roman and medieval settlement patterns in France
|
||||
weights = np.array([1.0, 1.5, 1.0, 1.5, 1.0, 1.5, 1.0, 1.5])
|
||||
|
||||
max_dist = int(100 / res)
|
||||
max_dist = min(int(100 / res), 300)
|
||||
padded = xp.pad(dem, max_dist, mode='constant', constant_values=xp.nan)
|
||||
|
||||
pos_sum = xp.zeros_like(dem)
|
||||
|
||||
Reference in New Issue
Block a user