{"id":27167,"library":"nerfacc","title":"NerfAcc","description":"A general NeRF acceleration toolbox that provides efficient occupancy grid-based ray marching and sampling for neural radiance fields. Current version 0.5.3, with rapid development and breaking changes between minor versions.","status":"active","version":"0.5.3","language":"python","source_language":"en","source_url":"https://github.com/KAIR-BAIR/nerfacc","tags":["nerf","volume-rendering","ray-marching","cuda","3d-reconstruction"],"install":[{"cmd":"pip install nerfacc","lang":"bash","label":"PyPI install (CUDA kernels JIT compiled on first run)"}],"dependencies":[{"reason":"Required for all operations; nerfacc builds CUDA kernels compatible with PyTorch","package":"torch","optional":false}],"imports":[{"note":"Old import path changed in v0.5.0","wrong":"from nerfacc.estimators import OccGridEstimator","symbol":"OccGridEstimator","correct":"from nerfacc import OccGridEstimator"},{"note":"ContractionType moved to top-level in v0.5.0","wrong":"from nerfacc.grid import ContractionType","symbol":"ContractionType","correct":"from nerfacc import ContractionType"}],"quickstart":{"code":"import torch\nfrom nerfacc import OccGridEstimator\n\ndevice = torch.device('cuda' if torch.cuda.is_available() else 'cpu')\n# Initialize an occupancy grid estimator for an unbounded scene (e.g., nerfstudio style)\nestimator = OccGridEstimator(\n    roi_aabb=[-2.0, -2.0, -2.0, 2.0, 2.0, 2.0],\n    resolution=256,\n    levels=2,\n).to(device)\n\n# Dummy occupancy update: random binary grid\nrandom_occ = torch.randint(0, 2, (estimator.binaries.shape[0], *estimator.binaries.shape[2:]), device=device, dtype=torch.bool)\nestimator.binaries = random_occ\n\n# Ray marching: generate rays and compute step sizes\nrays_o = torch.tensor([[0.0, 0.0, 0.0]], device=device)\nrays_d = torch.tensor([[1.0, 0.0, 0.0]], device=device)\nray_indices, starts, ends, hits = estimator.marching(rays_o, rays_d, near_plane=0.0, far_plane=10.0)\nprint(f\"Number of ray steps: {starts.shape[0]}\")","lang":"python","description":"Initialize a multi-level occupancy grid and perform ray marching on a dummy grid."},"warnings":[{"fix":"Use OccGridEstimator with levels parameter; replace ContractionType imports from nerfacc.grid with nerfacc.ContractionType.","message":"v0.5.0 rewrote 90% of the codebase: ContractionType removed from grid module, OccGridEstimator API changed (multi-level). Old code using single-level grid or contraction must be updated.","severity":"breaking","affected_versions":"<0.5.0"},{"fix":"Remove contraction argument; for unbounded scenes use multi-level grid or ProposalNetworkEstimator instead.","message":"Contraction for Occupancy Grid is no longer supported in v0.5.0 due to inefficiency for ray traversal. Attempting to use contraction with OccGridEstimator will raise error.","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Install compatible PyTorch + CUDA toolkit. Ensure torch.cuda.is_available() returns True.","message":"CUDA kernels are JIT compiled on first import; missing CUDA toolkit or incompatible PyTorch version will cause silent fallback to CPU or crash.","severity":"gotcha","affected_versions":"all"},{"fix":"Use estimator.binaries = occ.unsqueeze(0).unsqueeze(0) for single-level or initialize with levels=1.","message":"OccGridEstimator.binaries expects a boolean tensor of shape (levels, 1, res_x, res_y, res_z) after v0.5.0; single-level shape changed.","severity":"gotcha","affected_versions":">=0.5.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use 'from nerfacc import OccGridEstimator' instead of 'from nerfacc.estimators import OccGridEstimator'.","cause":"Import path changed in v0.5.0; estimators are now top-level.","error":"ModuleNotFoundError: No module named 'nerfacc.estimators'"},{"fix":"Use 'from nerfacc import ContractionType' (v0.5.0+) or 'from nerfacc.grid import ContractionType' (older versions).","cause":"ContractionType was moved to nerfacc.grid; but in v0.5.0 it's at top-level.","error":"AttributeError: module 'nerfacc' has no attribute 'ContractionType'"},{"fix":"Move estimator and rays to same device: estimator.to(device); rays_o = rays_o.to(device).","cause":"Mixing CPU and CUDA tensors in estimator methods; estimator and rays must be on same device.","error":"RuntimeError: Expected all tensors to be on the same device..."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}