Skip to content

Commit 4f1a990

Browse files
authored
Merge pull request #11 from ghanvert/CPU-execution
Added support for CPU execution
2 parents b3557bb + 2607a03 commit 4f1a990

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/accmt/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import os
1516
from datetime import timedelta
1617

1718
import torch
@@ -37,8 +38,14 @@ def allow_tf32(flag=True):
3738

3839
allow_tf32()
3940

41+
IS_CPU = bool(int(os.environ.get("ACCMT_CPU", 0)))
42+
IS_GPU = not IS_CPU
43+
4044
_init_kwargs = InitProcessGroupKwargs(timeout=timedelta(seconds=86400))
4145
_dataloader_config = DataLoaderConfiguration(use_seedable_sampler=True)
4246
accelerator = Accelerator(
43-
kwargs_handlers=[_init_kwargs], dataloader_config=_dataloader_config, step_scheduler_with_optimizer=False
47+
kwargs_handlers=[_init_kwargs],
48+
dataloader_config=_dataloader_config,
49+
step_scheduler_with_optimizer=False,
50+
cpu=IS_CPU,
4451
)

0 commit comments

Comments
 (0)