def get_shm_context_volume() -> k8s_schemas.V1Volume: """ Mount an tmpfs volume to /dev/shm. This will set /dev/shm size to half of the RAM of node. By default, /dev/shm is very small, only 64MB. Some experiments will fail due to lack of share memory, such as some experiments running on Pytorch. """ return k8s_schemas.V1Volume( name=constants.CONTEXT_VOLUME_SHM, empty_dir=k8s_schemas.V1EmptyDirVolumeSource(medium="Memory"), )
def get_volume( volume: str, claim_name: str = None, host_path: str = None, read_only: bool = None ) -> k8s_schemas.V1Volume: if claim_name: pv_claim = k8s_schemas.V1PersistentVolumeClaimVolumeSource( claim_name=claim_name, read_only=read_only ) return k8s_schemas.V1Volume(name=volume, persistent_volume_claim=pv_claim) if host_path: return k8s_schemas.V1Volume( name=volume, host_path=k8s_schemas.V1HostPathVolumeSource(path=host_path) ) empty_dir = k8s_schemas.V1EmptyDirVolumeSource() return k8s_schemas.V1Volume(name=volume, empty_dir=empty_dir)