Biophysically detailed multi-compartment models are powerful tools to explore computational principles of the brain and also serve as a theoretical framework to generate algorithms for artificial intelligence (AI) systems. However, the expensive computational cost severely limits the applications in both the neuroscience and AI fields. The major bottleneck during simulating detailed compartment models is the ability of a simulator to solve large systems of linear equations. Here, we present a novel Dendritic Hierarchical Scheduling (DHS) method to markedly accelerate such process. We theoretically prove that the DHS implementation is computationally optimal and accurate. This GPU-based method performs at 2-3 orders of magnitude higher speed than that of the classic serial Hines method in the conventional CPU platform. We build a DeepDendrite framework, which integrates the DHS method and the GPU computing engine of the NEURON simulator and demonstrate applications of DeepDendrite in neuroscience and AI tasks. We investigated how spatial patterns of spine inputs affects neuronal excitability in a detailed human pyramidal neuron model with 25,000 spines; and examined how dendrites protect morphologically detailed neural networks against adversarial attacks in typical image classification tasks.